cp's OEIS Frontend

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.

A126254 Number of distinct terms i^j for 1 <= i,j <= n.

Original entry on oeis.org

1, 3, 7, 11, 19, 28, 40, 50, 60, 76, 96, 115, 139, 163, 189, 207, 239, 270, 306, 340, 378, 417, 461, 503, 539, 585, 621, 670, 726, 779, 839, 881, 941, 1003, 1067, 1113, 1185, 1254, 1326, 1397, 1477, 1553, 1637, 1717, 1799, 1884, 1976, 2063, 2135, 2225
Offset: 1

Views

Author

Nick Hobson, Dec 24 2006

Keywords

Comments

An easy upper bound is n(n-1)+1 = A002061(n).

Examples

			a(4) = 11, as there are 11 distinct terms in 1^1=1, 1^2=1, 1^3=1, 1^4=1, 2^1=2, 2^2=4, 2^3=8, 2^4=16, 3^1=3, 3^2=9, 3^3=27, 3^4=81, 4^1=4, 4^2=16, 4^3=64, 4^4=256.
		

Crossrefs

Programs

  • Maple
    seq(nops({seq(seq(i^j, i=1..n),j=1..n)}),n=1..100); # Robert Israel, Feb 23 2015
  • PARI
    lim=50; z=listcreate(lim*(lim-1)+1); for(m=1, lim, for(i=1, 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=1, 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 A126254(n): return len({i**j for i in range(1,n+1) for j in range(1,n+1)}) # Chai Wah Wu, Oct 17 2023
  • R
    A126254 <- function(limit) {  if (limit == 1) { return(1) } ; num.powers <- c(1, rep(0, limit-1)) ; handled <- c(T, rep(F, limit-1)) ; for (base in 2:ceiling(sqrt(limit))) { if (!handled[base]) { num.handle <- floor(log(limit, base)) ; handled[base^(1:num.handle)] <- T ; num.powers[base] <- length(unique(as.vector(outer(1:num.handle, 1:limit)))) }} ; num.powers[!handled] <- limit ; sum(num.powers) } ; A126254(50) # John Silberholz, Feb 23 2015