A052340 Record numbers of iterations reached in A050412.
1, 2, 3, 4, 7, 24, 2552, 800516
Offset: 1
Formula
Extensions
a(8) from the b-file at A050412 added by Amiram Eldar, Jul 25 2019
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.
a040081 = length . takeWhile ((== 0) . a010051) . iterate ((+ 1) . (* 2)) . (subtract 1) -- Reinhard Zumkeller, Mar 05 2012
Table[m = 0; While[! PrimeQ[n*2^m - 1], m++]; m, {n, 100}] (* Arkadiusz Wesolowski, Sep 04 2011 *)
a(n)=for(k=0,2^16,if(ispseudoprime(n*2^k-1), return(k))) \\ Eric Chen, Jun 01 2015
from sympy import isprime def a(n): m = 0 while not isprime(n*2**m - 1): m += 1 return m print([a(n) for n in range(1, 88)]) # Michael S. Branicky, Feb 01 2021
a(4)=19 because 4 -> 9 (composite) -> 19 (prime).
Table[NestWhile[2#+1&,2n+1,!PrimeQ[#]&,1,1000],{n,60}] (* Harvey P. Dale, May 08 2011 *)
a(n)=while(!isprime(n=2*n+1),);n \\ oo loop when a(n) = 0. - Charles R Greathouse IV, May 08 2011
a038699 = until ((== 1) . a010051) ((+ 1) . (* 2)) . (subtract 1) -- Reinhard Zumkeller, Mar 05 2012
getm[n_]:=Module[{m=0},While[!PrimeQ[n 2^m-1],m++];n 2^m-1]; Array[getm,80] (* Harvey P. Dale, Apr 24 2011 *)
a(15)=4 because (2*15+1)+2^k is composite for k=1,2,3 and prime for k=4.
a(n) = {my(k=1); while (! isprime((2*n+1)+2^k), k++); k;} \\ Michel Marcus, Feb 26 2018
max = 10^6; (* this maximum value of m is sufficient up to n=1000 *) a[1] = 2; a[2] = 0; a[n_] := For[m = 1, m <= max, m++, If[PrimeQ[(2*n - 1)*2^m - 1], Return[m]]] /. Null -> -1; Reap[ Do[ Print[ "a(", n, ") = ", a[n]]; Sow[a[n]], {n, 1, 100}]][[2, 1]] (* Jean-François Alcover, Nov 15 2013 *)
Array[Function[k, SelectFirst[Range@300, PrimeQ[k 2^# - 1] &]][2 # - 1] &, 102] (* Michael De Vlieger, Jan 12 2018 *) smk[n_]:=Module[{m=1,k=2n-1},While[!PrimeQ[k 2^m-1],m++];m]; Array[smk,120] (* Harvey P. Dale, Dec 26 2023 *)
forstep(k=1,301,2,n=1;while(!isprime(k*2^n-1),n++);print1(n,","))
a(1) = 1 is not a prime, so a(2) = 2*1+1 = 3. a(2) is a prime, so a(3) = prime(3)-1 = 4. a(4) = 2*4+1 = 9.
a[n_] := a[n] = If[!PrimeQ[a[n-1]], 2*a[n-1] + 1, Prime[n]-1]; a[1] = 1; Array[a, 60] (* Amiram Eldar, Jul 25 2024 *) nxt[{n_,a_}]:={n+1,If[!PrimeQ[a],2a+1,Prime[n+1]-1]}; NestList[nxt,{1,1},60][[;;,2]] (* Harvey P. Dale, Jul 28 2024 *)
from itertools import islice from sympy import isprime, nextprime def A374965_gen(): # generator of terms a, p = 1, 3 while True: yield a a, p = p-1 if isprime(a) else (a<<1)+1, nextprime(p) A374965_list = list(islice(A374965_gen(),30)) # Chai Wah Wu, Jul 29 2024
Comments