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.
%I A360738 #36 Mar 05 2023 11:37:11 %S A360738 1,1,2,1,2,1,4,2,-1,1,16,1,4,2,2,1,2,1,18,2,2,1,4,2,-1,6,2,1,4,1,6,-1, %T A360738 2,12,312,1,12,2,348,1,2,1,4,4,18,1,126,18,-1,2,4228,1,10,2,16,6,2,1, %U A360738 2,1,6,2,4,-1,18,1,18,4,2,1,2,1,4,4,2,40,2,1,4,2,-1,1,4,16,4,10,6,1,2,2,4420 %N A360738 a(n) = A084740(n) - 1. %C A360738 a(n) is the smallest k such that 1 + n + n^2 + ... + n^k is a prime. a(n) = -1 if no such k exists. %C A360738 From _Jon E. Schoenfield_, Feb 22 2023: (Start) %C A360738 Let s(n,k) = Sum_{j=0..k} n^j. Then if k+1 is not a prime, s(n,k) is divisible by s(n,j) for some positive j < k, so s(n,k) is not a prime. %C A360738 Additionally, if n = 2^d (for d >= 1), then if k+1 is a prime, s(n,k) is usually divisible by 2^(k+1)-1. For d <= 16, it seems that the only exceptions are s(4,1) = 5, s(8,2) = 73, s(16,1) = 17, s(32,4) = 601*1801, s(64,1) = 5*13, s(64,2) = 3*19*73, s(128,6) = 4432676798593, s(256,1) = 257, s(512,2) = 262657, s(1024,1) = 5^2*41, s(1024,4) = 251*601*1801*4051, s(2048,10) = 727*p31, s(4096,1) = 17*241, s(4096,2) = 3*19*37*73*109, s(8192,12) = 4057*6740339310641*p31, s(16384,1) = 5*29*113, s(16384,6) = 4363953127297*4432676798593, s(32768,2) = 73*631*23311, s(32768,4) = 601*1801*100801*10567201, s(65536,1) = 65537, and s(131072,16) = 12761663*179058312604392742511009*p52. %C A360738 So a(32) = -1 because the sum s(32,k) is not prime for any k: %C A360738 for each k such that k+1 is not a prime, s(32,k) is divisible by s(32,j) for some positive j < k; %C A360738 for each k such that k+1 is a prime except for k=4, s(32,k) is divisible by 2^(k+1)-1; and %C A360738 s(32,4) = 601*1801 is a nonprime. %C A360738 Similarly, a(64) = -1 because the sum s(64,k) is not prime for any k: %C A360738 for each k such that k+1 is not a prime, s(64,k) is divisible by s(64,j) for some positive j < k; %C A360738 for each k such that k+1 is a prime except for k=1 and k=2, s(64,k) is divisible by 2^(k+1)-1; and %C A360738 s(64,1) = 5*13 and s(64,2) = 3*19*73 are nonprime. (End) %F A360738 a((2m+1)^2) = -1 for m >= 1. %o A360738 (PARI) a(n, lim=oo)=if((issquare(n)&&n%2==1&&n>1)||n==32||n==64, -1, my(s=1); for(k=1, lim, s+=n^k; if(ispseudoprime(s), return(k)) ); oo) \\ _Andrew Howroyd_, Feb 22 2023 %Y A360738 Cf. A084740. %K A360738 sign %O A360738 1,3 %A A360738 _Ya-Ping Lu_, Feb 18 2023 %E A360738 a(32)-a(79) from _Jon E. Schoenfield_, Feb 21 2023 %E A360738 a(80)-a(91) from _Andrew Howroyd_, Feb 22 2023