login
Number of digits in primorial base expansion of n that are maximal possible in their positions.
4

%I #14 Mar 13 2024 01:50:30

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

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

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

%N Number of digits in primorial base expansion of n that are maximal possible in their positions.

%H Antti Karttunen, <a href="/A328616/b328616.txt">Table of n, a(n) for n = 0..32768</a>

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

%F For all n >= 1, a(A057588(n)) = n.

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

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

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

%o (PARI) A328616(n) = { my(s=0, p=2); while(n, s += ((p-1)==(n%p)); n = n\p; p = nextprime(1+p)); (s); };

%Y Cf. A002110, A049345, A276086, A328114, A328614, A328615.

%Y Cf. A057588 (positions of records, and the first occurrence of each n > 0).

%Y Cf. also A260736.

%K nonn,base

%O 0,6

%A _Antti Karttunen_, Oct 22 2019