OFFSET
0,1
LINKS
Reinhard Zumkeller, Table of n, a(n) for n = 0..10000
Wikipedia, Morse code
FORMULA
a(n) A007089(A060110(n)) = a(floor(n/10))*10^6 + a(n%10) for n > 9 and a(n) = 33333 - a(n-5) for n%10 > 4, where % is the modulo (remainder) operator. - M. F. Hasler, Jun 22 2020
EXAMPLE
a(10) = 12222022222 since 1 is ".----" and 0 is "-----".
MATHEMATICA
With[{a = Association@ Array[# -> If[# < 6, PadRight[ConstantArray[1, #], 5, 2], PadRight[ConstantArray[2, # - 5], 5, 1]] &, 10, 0]}, Array[FromDigits@ Flatten@ Riffle[Map[Lookup[a, #] &, IntegerDigits[#]], 0] &, 25]] (* Michael De Vlieger, Nov 02 2020 *)
PROG
(Haskell)
import Data.List (inits, tails)
a060109 n = if n == 0 then 22222 else read (conv n) :: Integer where
conv 0 = []
conv x = conv x' ++ mCode !! d where (x', d) = divMod x 10
mCode = map ('0' :) (mc ++ (reverse $ init $ tail $ map reverse mc))
mc = zipWith (++) (inits "111111") (tails "22222")
-- Reinhard Zumkeller, Feb 20 2015
(PARI) apply( {A060109(n)=if(n>9, self()(n\10)*10^6)+fromdigits([1+(abs(k-n%10)>2)|k<-[3..7]])}, [0..39]) \\ M. F. Hasler, Jun 22 2020
CROSSREFS
KEYWORD
base,nonn
AUTHOR
Henry Bottomley, Feb 28 2001
STATUS
approved