cp's OEIS Frontend

This is a front-end for the Online Encyclopedia of Integer Sequences, made by Christian Perfect. The idea is to provide OEIS entries in non-ancient HTML, and then to think about how they're presented visually. The source code is on GitHub.

A360108 Sum of squares of digits of primorial base expansion of n.

Original entry on oeis.org

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
Offset: 0

Views

Author

Antti Karttunen, Jan 28 2023

Keywords

Examples

			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.
		

Crossrefs

Cf. A002110 (positions of 1's), A049345, A090885, A276086, A276150.
Cf. also A003132.

Programs

  • 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 *)
  • 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); };

Formula

a(n) = A090885(A276086(n)).
For all n >= 0, a(2n+1) = 1 + a(2n).