OFFSET
0,4
LINKS
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
Antti Karttunen, Jan 28 2023
STATUS
approved