[go: up one dir, main page]

login
Sum of squares of digits of primorial base expansion of n.
1

%I #15 Mar 06 2024 01:02:29

%S 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,

%T 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,

%U 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

%N Sum of squares of digits of primorial base expansion of n.

%H Antti Karttunen, <a href="/A360108/b360108.txt">Table of n, a(n) for n = 0..30030</a>

%H <a href="/index/Pri#primorialbase">Index entries for sequences related to primorial base</a>.

%F a(n) = A090885(A276086(n)).

%F For all n >= 0, a(2n+1) = 1 + a(2n).

%e 5 in primorial base (A049345) is written as "21" (because 5 = 2*2 + 1*1), therefore a(5) = 2^2 + 1^2 = 5.

%e 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.

%e 24 in primorial base is written as "400" (because 24 = 4*6 + 0*2 + 0*1), therefore a(24) = 4^2 = 16.

%t 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 *)

%o (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); };

%Y Cf. A002110 (positions of 1's), A049345, A090885, A276086, A276150.

%Y Cf. also A003132.

%K nonn,base,easy,look

%O 0,4

%A _Antti Karttunen_, Jan 28 2023