OFFSET
1,2
COMMENTS
The length of the m-th run of {a(n)} is the length of the (m-1)-st run of A031218 for m > 1. - Colin Linzer, Mar 08 2024
LINKS
David W. Wilson, Table of n, a(n) for n = 1..10000
Eric Weisstein's World of Mathematics, Prime Power.
FORMULA
a(A110654(n+1)) = A188666(n). - Reinhard Zumkeller, Apr 25 2011, corrected by M. F. Hasler, Jul 25 2015
a(n) = A188666(2n-1). - M. F. Hasler, Jul 25 2015
MAPLE
N:= 1000: # to get all terms <= N
Primes:= select(isprime, {$1..N}):
PPs:= {1} union Primes:
for k from 1 to ilog2(N) do
PPs:= PPs union map(`^`, select(`<=`, Primes, floor(N^(1/k))), k)
od:
PPs:= sort(convert(PPs, list)):
1, seq(PPs[i]$(PPs[i]-PPs[i-1]), i=2..nops(PPs)); # Robert Israel, Jul 23 2015
MATHEMATICA
Insert[Table[m:=n; While[Not[Length[FactorInteger[m]]==1], m++ ]; m, {n, 2, 100}], 1, 1] (* Stefan Steinerberger, Apr 17 2006 *)
a[n_] := NestWhile[# + 1 &, n, Not@*PrimePowerQ]; (* Matthew House, Jul 14 2015, v6.0+ *)
a[ n_] := If[ n < 2, Boole[n == 1], Module[{m = n}, While[ ! PrimePowerQ[ m], m++]; m]]; (* Michael Somos, Mar 06 2018 *)
a[ n_] := If[ n < 1, 0, Module[{m = n}, While[ Length[ FactorInteger @ m ] != 1, m++]; m]]; (* Michael Somos, Mar 06 2018 *)
PROG
(PARI) {a(n) = if( n<1, 0, while(matsize(factor(n))[1]>1, n++); n)}; /* Michael Somos, Jul 16 2002 */
(PARI) a(n)=if(n>1, while(!isprimepower(n), n++)); n \\ Charles R Greathouse IV, Feb 01 2013
(Sage) [next_prime_power(n) for n in range(72)] # Zerinvary Lajos, Jun 13 2009
(Haskell)
a000015 n = a000015_list !! (n-1)
a000015_list = 1 : concat
(zipWith(\pp qq -> replicate (fromInteger (pp - qq)) pp)
(tail a000961_list) a000961_list)
-- Reinhard Zumkeller, Nov 17 2011, Apr 25 2011
(Python)
from itertools import count
from sympy import factorint
def A000015(n): return next(filter(lambda m:len(factorint(m))<=1, count(n))) # Chai Wah Wu, Oct 25 2024
CROSSREFS
KEYWORD
nonn,easy,changed
AUTHOR
EXTENSIONS
More terms from Michael Somos, Jul 16 2002
STATUS
approved