jejuneliability69_1
=7; a[n_]:=Sum[(Floor[a[n-1]/10^k]-10*Floor[a[n-1]/10^(k+1)]) ^ (2) , {k, 0, Floor[Log[10, a[n-1]]] }] Table[a[n], {n, 1, 10}] (* José de Jesús Camacho Medina, Mar 29 2014 *) PROG (Haskell) a007770 n = a007770_list !! (n-1) a007770_list = filter ((== 1) . a103369) [1..] -- Reinhard Zumkeller, Aug 24 2011 (PARI) ssd(n)=n=digits(n); sum(i=1, #n, n[i]^2) is(n)=while(n>6, n=ssd(n)); n==1 \\ Charles R Greathouse IV, Nov 20 2012 (Python) def ssd(n): return sum(int(d)**2 for d in str(n)) def ok(n): while n not in [1, 4]: n = ssd(n) # iterate until fixed point or in cycle return n==1 def aupto(n): return [k for k in range(1, n+1) if ok(k)] print(aupto(338)) # Michael S. Branicky, Jan 07 2021
Клубы
Niger Team
Niger Team 206 пользователей