Search: id:a277486
|
|
A277486
|
|
a(n) = number of integers one more than a prime encountered before reaching (n^2)-1 when starting from k = ((n+1)^2)-1 and iterating map k -> k - A002828(k).
|
|
+0
7
|
|
|
1, 2, 0, 2, 2, 2, 0, 2, 1, 2, 1, 3, 1, 3, 1, 3, 3, 2, 3, 3, 5, 4, 1, 4, 3, 4, 2, 4, 4, 2, 4, 4, 4, 3, 3, 4, 3, 4, 5, 5, 5, 4, 4, 6, 6, 3, 3, 9, 4, 5, 6, 9, 4, 6, 4, 4, 8, 6, 5, 7, 5, 9, 5, 5, 7, 8, 6, 11, 5, 9, 4, 7, 9, 9, 6, 10, 5, 5, 17, 4, 10, 9, 10, 7, 3, 3, 10, 8, 7, 10, 6, 9, 5, 10, 10, 10, 8, 11, 6, 9, 10, 7, 7, 7, 7, 12, 9, 11, 13, 9, 12, 6, 10, 9, 6
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,2
|
|
LINKS
|
|
|
FORMULA
|
|
|
EXAMPLE
|
For n=6, we start iterating from k = ((6+1)^2)-1 = 48, and then 48 - A002828(48) = 45, 45 - A002828(45) = 43, 43 - A002828(43) = 40, 40 - A002828(40) = 38, and 38 - A002828(38) = 35 (which is 6^2 - 1), and when we subtract one from each, only 47 and 37 are primes, thus a(6) = 2.
For n=7, we start iterating from k = ((7+1)^2)-1 = 63, and 63 -> 59, 59 -> 56, 56 -> 53, 53 -> 51, 51 -> 48 (which is 7^2 - 1), and subtracting one from each of 63, 59, 56, 53 and 51, doesn't yield a prime for any, thus a(7)=0. (Note that even though 48-1 = 47 is a prime, it is not included in the count for n=7).
|
|
PROG
|
(PARI)
istwo(n:int)=my(f); if(n<3, return(n>=0); ); f=factor(n>>valuation(n, 2)); for(i=1, #f[, 1], if(bitand(f[i, 2], 1)==1&&bitand(f[i, 1], 3)==3, return(0))); 1
isthree(n:int)=my(tmp=valuation(n, 2)); bitand(tmp, 1)||bitand(n>>tmp, 7)!=7
A002828(n)=if(issquare(n), !!n, if(istwo(n), 2, 4-isthree(n))) \\ From _Charles R Greathouse_ IV, Jul 19 2011
A277486(n) = { my(orgk = ((n+1)^2)-1); my(k = orgk, s = 0); while(((k == orgk) || !issquare(1+k)), s = s + if(isprime(k-1), 1, 0); k = k - A002828(k)); s; };
for(n=1, 10000, write("b277486.txt", n, " ", A277486(n)));
(Scheme)
(define (A277486 n) (let ((org_k (- (A000290 (+ 1 n)) 1))) (let loop ((k org_k) (s 0)) (if (and (< k org_k) (= 1 (A010052 (+ 1 k)))) s (loop (- k (A002828 k)) (+ s (A010051 (+ -1 k))))))))
|
|
CROSSREFS
|
|
|
KEYWORD
|
nonn
|
|
AUTHOR
|
|
|
STATUS
|
approved
|
|
|
Search completed in 0.006 seconds
|