OFFSET
2,2
COMMENTS
An easy upper bound is (n-1)^2 = A000290(n-1).
LINKS
Eric M. Schmidt, Table of n, a(n) for n = 2..10000
Project Euler, Problem 29: Distinct powers.
EXAMPLE
a(4) = 8 as there are 8 distinct terms in 2^2=4, 2^3=8, 2^4=16, 3^2=9, 3^3=27, 3^4=81, 4^2=16, 4^3=64, 4^4=256.
MATHEMATICA
SetAttributes[a, {Listable, NumericFunction}]
a[n_ /; n < 2] := "error"
a[2] := 1
a[n_Integer?IntegerQ /; n > 2] :=
Length[DeleteDuplicates[
Distribute[f[Range[2, n], Range[2, n]], List,
f] /. {f ->
Power}]](*By using Distribute instead of Outer I avoid having to use Flatten on Outer*)
a[Range[2, 100]]
(* Peter Cullen Burbery, Aug 15 2023 *)
PROG
(PARI) lim=51; z=listcreate((lim-1)^2); for(m=2, lim, for(i=2, m, x=factor(i); x[, 2]*=m; s=Str(x); f=setsearch(z, s, 1); if(f, listinsert(z, s, f))); t=factor(m); for(j=2, m, x=t; x[, 2]=j*t[, 2]; s=Str(x); f=setsearch(z, s, 1); if(f, listinsert(z, s, f))); print1(#z, ", "))
(Python)
def A126255(n): return len({i**j for i in range(2, n+1) for j in range(2, n+1)}) # Chai Wah Wu, Oct 17 2023
CROSSREFS
KEYWORD
easy,nonn
AUTHOR
Nick Hobson, Dec 24 2006
STATUS
approved