login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A059707 If all digits have the same parity, stop; otherwise write down the number formed by the even digits and the number formed by the odd digits and multiply them; repeat. 4

%I #17 Jul 07 2014 12:32:19

%S 0,1,2,3,4,5,6,7,8,9,0,11,2,13,4,15,6,17,8,19,20,2,22,6,24,0,26,4,28,

%T 8,0,31,6,33,2,35,8,37,24,39,40,4,42,2,44,20,46,28,48,8,0,51,0,53,20,

%U 55,0,57,40,59,60,6,62,8,64,0,66,42,68,20,0,71,4,73,28,75,42

%N If all digits have the same parity, stop; otherwise write down the number formed by the even digits and the number formed by the odd digits and multiply them; repeat.

%C a(A059708(n)) = A059708(n). - _Reinhard Zumkeller_, Jun 15 2012

%H Reinhard Zumkeller, <a href="/A059707/b059707.txt">Table of n, a(n) for n = 0..10000</a>

%e 89 -> 8*9 = 72 -> 7*2 = 14 -> 1*4 = 4, stop, so a(89) = 4.

%e 33278 -> 28*337 = 9436 -> 46*93 = 4278 -> 42*78 -> 2996 -> 26*99 = 2574 -> 24*57 = 1368 -> 68*13 = 884, stop, so a(33278) = 884.

%t f[n_] := (id = IntegerDigits[n]; oddDigits = Select[id, OddQ]; evenDigits = Select[id, EvenQ]; Which[oddDigits == {}, FromDigits[evenDigits], evenDigits == {}, FromDigits[oddDigits], True, FromDigits[evenDigits] * FromDigits[oddDigits]]); a[n_] := FixedPoint[f, n]; Table[a[n], {n, 0, 76}] (* _Jean-François Alcover_, May 16 2013 *)

%t sp[n_]:=Module[{idn=IntegerDigits[n],e,o},e=Select[idn,EvenQ];o= Select[ idn,OddQ];If[Min[Length[o],Length[e]]>0,FromDigits[o] FromDigits[e], n]]; Table[FixedPoint[sp,i],{i,0,80}] (* _Harvey P. Dale_, Jun 05 2014 *)

%o (Haskell)

%o import Data.List (unfoldr)

%o a059707 n = if u == n || v == n then n else a059707 (u * v) where

%o (u,v) = foldl (\(x,y) d -> if odd d then (10*x+d,y) else (x,10*y+d))

%o (0,0) $ reverse $ unfoldr

%o (\z -> if z == 0 then Nothing else Just $ swap $ divMod z 10) n

%o -- _Reinhard Zumkeller_, Jun 15 2012

%Y Cf. A059708, A059717.

%K nonn,base,easy,nice,look

%O 0,3

%A _N. J. A. Sloane_, Feb 07 2001

%E a(50) corrected by _Reinhard Zumkeller_, Jun 15 2012

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 25 16:45 EDT 2024. Contains 371989 sequences. (Running on oeis4.)