cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

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.

Original entry on oeis.org

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, 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, 55, 0, 57, 40, 59, 60, 6, 62, 8, 64, 0, 66, 42, 68, 20, 0, 71, 4, 73, 28, 75, 42
Offset: 0

Views

Author

N. J. A. Sloane, Feb 07 2001

Keywords

Comments

a(A059708(n)) = A059708(n). - Reinhard Zumkeller, Jun 15 2012

Examples

			89 -> 8*9 = 72 -> 7*2 = 14 -> 1*4 = 4, stop, so a(89) = 4.
33278 -> 28*337 = 9436 -> 46*93 = 4278 -> 42*78 -> 2996 -> 26*99 = 2574 -> 24*57 = 1368 -> 68*13 = 884, stop, so a(33278) = 884.
		

Crossrefs

Programs

  • Haskell
    import Data.List (unfoldr)
    a059707 n = if u == n || v == n then n else a059707 (u * v) where
       (u,v) = foldl (\(x,y) d -> if odd d then (10*x+d,y) else (x,10*y+d))
            (0,0) $ reverse $ unfoldr
            (\z -> if z == 0 then Nothing else Just $ swap $ divMod z 10) n
    -- Reinhard Zumkeller, Jun 15 2012
  • Mathematica
    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 *)
    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 *)

Extensions

a(50) corrected by Reinhard Zumkeller, Jun 15 2012