|
|
A360108
|
|
Sum of squares of digits of primorial base expansion of n.
|
|
1
|
|
|
0, 1, 1, 2, 4, 5, 1, 2, 2, 3, 5, 6, 4, 5, 5, 6, 8, 9, 9, 10, 10, 11, 13, 14, 16, 17, 17, 18, 20, 21, 1, 2, 2, 3, 5, 6, 2, 3, 3, 4, 6, 7, 5, 6, 6, 7, 9, 10, 10, 11, 11, 12, 14, 15, 17, 18, 18, 19, 21, 22, 4, 5, 5, 6, 8, 9, 5, 6, 6, 7, 9, 10, 8, 9, 9, 10, 12, 13, 13, 14, 14, 15, 17, 18, 20, 21, 21, 22
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
0,4
|
|
LINKS
|
|
|
FORMULA
|
For all n >= 0, a(2n+1) = 1 + a(2n).
|
|
EXAMPLE
|
5 in primorial base (A049345) is written as "21" (because 5 = 2*2 + 1*1), therefore a(5) = 2^2 + 1^2 = 5.
23 in primorial base is written as "321" (because 23 = 3*6 + 2*2 + 1*1), therefore a(23) = 3^2 + 2^2 + 1^2 = 14.
24 in primorial base is written as "400" (because 24 = 4*6 + 0*2 + 0*1), therefore a(24) = 4^2 = 16.
|
|
MATHEMATICA
|
a[n_] := Module[{k = n, p = 2, s = 0, r}, While[{k, r} = QuotientRemainder[k, p]; k != 0 || r != 0, s += r^2; p = NextPrime[p]]; s]; Array[a, 100, 0] (* Amiram Eldar, Mar 06 2024 *)
|
|
PROG
|
(PARI) A360108(n) = { my(s=0, p=2, d); while(n, d = (n%p); s += d^2; n = (n-d)/p; p = nextprime(1+p)); (s); };
|
|
CROSSREFS
|
|
|
KEYWORD
|
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
|