Skip to main content
added 152 characters in body
Source Link
Giuseppe
  • 29.4k
  • 3
  • 33
  • 106

R, 6262 60 bytes

function(n,y=outer(1:n,1+12:n,"^"))c(max(y[y<=n]),min(y[y>=n])) 

Try it online!Try it online!

Brute force approach: generate all powers of 1..n raised to 2..n and find and return least upper bound and greatest lower bound.

R, 62 bytes

function(n,y=outer(1:n,1+1:n,"^"))c(max(y[y<=n]),min(y[y>=n])) 

Try it online!

R, 62 60 bytes

function(n,y=outer(1:n,2:n,"^"))c(max(y[y<=n]),min(y[y>=n])) 

Try it online!

Brute force approach: generate all powers of 1..n raised to 2..n and find and return least upper bound and greatest lower bound.

Source Link
Giuseppe
  • 29.4k
  • 3
  • 33
  • 106

R, 62 bytes

function(n,y=outer(1:n,1+1:n,"^"))c(max(y[y<=n]),min(y[y>=n])) 

Try it online!