login
A328616
Number of digits in primorial base expansion of n that are maximal possible in their positions.
4
0, 1, 0, 1, 1, 2, 0, 1, 0, 1, 1, 2, 0, 1, 0, 1, 1, 2, 0, 1, 0, 1, 1, 2, 1, 2, 1, 2, 2, 3, 0, 1, 0, 1, 1, 2, 0, 1, 0, 1, 1, 2, 0, 1, 0, 1, 1, 2, 0, 1, 0, 1, 1, 2, 1, 2, 1, 2, 2, 3, 0, 1, 0, 1, 1, 2, 0, 1, 0, 1, 1, 2, 0, 1, 0, 1, 1, 2, 0, 1, 0, 1, 1, 2, 1, 2, 1, 2, 2, 3, 0, 1, 0, 1, 1, 2, 0, 1, 0, 1, 1, 2, 0, 1, 0, 1
OFFSET
0,6
FORMULA
For all n >= 1, a(A057588(n)) = n.
EXAMPLE
In primorial base (see A049345), the maximum digit value that can occur in the k-th position from the right (with k=1 standing for the rightmost, i.e., the least significant digit position) is A000040(k)-1, and it is for the terms of A057588 (primorial numbers minus one) where all significant digits are maximal allowed for their positions, e.g. 209 is written as "6421" because 209 = 6*30 + 4*6 + 2*2 + 1*1, thus a(209) = 4.
87 is written as "2411" because 87 = 2*A002110(3) + 4*A002110(2) + 1*A002110(1) + 1*A002110(0) = 2*30 + 4*6 + 1*2 + 1*1. Only the digit positions 1 and 3 are occupied with maximum digits allowed in those positions (that are 1 and 4, being one less than the corresponding primes, 2 and 5), thus a(87) = 2.
MATHEMATICA
a[n_] := Module[{k = n, p = 2, s = {}, r}, While[{k, r} = QuotientRemainder[k, p]; k != 0 || r != 0, AppendTo[s, r]; p = NextPrime[p]]; Count[Prime[Range[1, Length[s]]] - s, 1]]; a[0] = 0; Array[a, 100, 0] (* Amiram Eldar, Mar 13 2024 *)
PROG
(PARI) A328616(n) = { my(s=0, p=2); while(n, s += ((p-1)==(n%p)); n = n\p; p = nextprime(1+p)); (s); };
CROSSREFS
Cf. A057588 (positions of records, and the first occurrence of each n > 0).
Cf. also A260736.
Sequence in context: A321396 A141747 A239706 * A260736 A342656 A293896
KEYWORD
nonn,base
AUTHOR
Antti Karttunen, Oct 22 2019
STATUS
approved