login

Reminder: The OEIS is hiring a new managing editor, and the application deadline is January 26.

Largest prime x such that x/(n^k), rounded up, is 1 or a prime for all positive integer values of k.
1

%I #4 Mar 30 2012 17:26:59

%S 5,109,163,751,37181,1220423,420001,59757913,16660807,199067023,

%T 766462903201,641418438961,610994816525833,834251799269401,

%U 46727045369489101,21346113465023,42439483778365061,17596652626197454349,1525870657210709129

%N Largest prime x such that x/(n^k), rounded up, is 1 or a prime for all positive integer values of k.

%C The program below is for C++ and does not work for numbers above a certain point due to integer restrictions.

%e S(3)=109 because 109 is a prime, 109/3 rounded up, or 37, is a prime; 109/3^2 rounded up, or 13, is a prime; 109/3^3 rounded up, or 5, is a prime;109/3^4 rounded up, or 2, is a prime; 109/3^5 rounded up is one.

%o #include <iostream> #include <cmath> #include <tchar.h> using namespace std; unsigned long int sqrot; unsigned long int test; void primetest (unsigned long long int& x, bool& t){ sqrot=10000000000; test=2; while(sqrot>test && x>test && x%test!=0){ test=test+1; } if(sqrot==test || x==test){ t=true; }else{ t=false; }} int main() { int a; int b; unsigned int k; unsigned long long int c; unsigned long long int prime; unsigned long long int array[2000]; int number=2; bool t; unsigned int d=1; number=2; while(number>1){ array[1]=1; a=1; b=1; while(a<=b){ prime=number*array[a]; k=number-1; while (prime-k<= prime){ c=prime-k; primetest(c,t); if(t==true){ b++; array[b]=c; if(c>d){ d=c; }else{} }else{} k--; } a++; } cout<<d<<","; number++; d=1; } cin>>a; return 0; }

%o Contribution from _Max Alekseyev_, May 21 2009: (Start)

%o (PARI) { a(n,q) = local(t,b,r); t=(q-1)*n; b=q*n; r=[]; while(1, t=nextprime(t+1); if(t>b,break); r=concat(r,[t]); );r }

%o { A128110(n,s=1) = local(m,t); m=s; t=a(n,s); for(k=1,#t, m=max(m,A128110(n,t[k]));); m } (End)

%K nonn

%O 2,1

%A Alex Smith (Indeed123(AT)gmail.com), Feb 15 2007

%E Corrected and extended by _Max Alekseyev_, May 21 2009