A271268 Concatenate sum of digits of previous term and product of digits of previous term, starting with 8.
8, 88, 1664, 17144, 17112, 1214, 88, 1664, 17144, 17112, 1214, 88, 1664, 17144, 17112, 1214, 88, 1664, 17144, 17112, 1214, 88, 1664, 17144, 17112, 1214, 88, 1664, 17144, 17112, 1214, 88, 1664, 17144, 17112, 1214, 88, 1664, 17144, 17112, 1214, 88, 1664, 17144
Offset: 0
Links
- Peter Kagey, Table of n, a(n) for n = 0..9999
- Index entries for linear recurrences with constant coefficients, signature (0,0,0,0,1).
Crossrefs
Cf. A271220.
Programs
-
Haskell
a271268 = 8 : cycle [88, 1664, 17144, 17112, 1214] -- Correction by Peter Kagey, Aug 25 2016
-
Mathematica
NestList[FromDigits@ Join[IntegerDigits@ Total@ #, IntegerDigits[Times @@ #]] &@ IntegerDigits@ # &, 8, 48] (* Michael De Vlieger, Aug 26 2016 *) PadRight[{8},50,{1214,88,1664,17144,17112}] (* Harvey P. Dale, Oct 04 2017 *)
-
PARI
/* first rather for illustration, second is more efficient to get a(n) */ A271268_first(n)=vector(n,i,n=if(i>1,eval(Str(vecsum(n=digits(n)),vecprod(n))), 8)) apply( {A271268(n)=[8, 17112, 1214, 88, 1664, 17144][n%5+(n>1)*2]}, [1..15]) \\ M. F. Hasler, Apr 01 2025
-
Python
from functools import reduce from operator import mul def product(seq): return reduce(mul, seq, 1) def conversion(n): n = str(n) return str(sum(int(i) for i in n)) + \ str(product(int(i) for i in n)) def a271268(n): if n == 1: return 8 else: r = 8 while n > 1: r = conversion(r) n -= 1 return int(r)
-
Python
from math import prod # first program for illustration - better use the second one def A271268_gen(n = 8): # optional parameter defines starting value while True: yield n; d=list(map(int,str(n))); n=int(f"{sum(d)}{prod(d)}") def A271268(n = None): # if no n given, generator of "infinite" sequence return (8, 17112, 1214, 88, 1664, 17144)[n%5+1 if n>1 else 0] if n \ else (A271268(n)for n in range(1,1<<59)) # M. F. Hasler, Apr 01 2025
Extensions
Offset changed to 0 by Sean A. Irvine, Apr 12 2025
Comments