%I #28 Oct 06 2023 10:40:57
%S 1,2,1,4,4,3,2,8,18,6,5,4,3,2,1,16,8,7,6,5,4,3,2,1,2,10,54,8,7,6,5,32,
%T 3,2,1,28,12,11,10,9,8,7,6,5,4,3,2,1,15,14,13,12,11,10,9,8,7,6,5,4,3,
%U 2,1,64,16,15,14,13,12,11,10,9,8,7,6,5,4,3,2,1,162,18,17,16,15,14,13,12,11,10
%N Let k be the largest number such that n is a k-th power; then a(n) is the least positive number m such that m + n is a (k+1)st power.
%H David A. Corneth, <a href="/A086484/b086484.txt">Table of n, a(n) for n = 1..10001</a>
%e From _David A. Corneth_, Sep 24 2023: (Start)
%e For n = 3, k = 1 as 3 = 3^1 is a 1st power (the gcd of the exponents is 1). Hence we look for m such that m + 3 is a (1+1)th power, i.e., a 2nd power. The next 2nd power after 3 is 4 and so m + 3 = 4 so a(n) = m = 4-3 = 1.
%e For n = 36, k = 2 as 36 = 2^2 * 3^2 is a 2nd power (the gcd of the exponents is 2). Hence we look for m such that m + 36 is a (2+1)th power, i.e., a 3rd power. The next 3rd power after 36 is 64 and so m + 36 = 64 so a(n) = m = 64 - 36 = 28. (End)
%o (PARI) print1(1", "); for (n = 2, 100, f = factor(n); g = f[1, 2]; for (i = 2, matsize(f)[1], g = gcd(g, f[i, 2])); x = sqrtn(n, g+1); print1(round(ceil(x))^(g + 1) - n, ", ")); \\ _David Wasserman_, Mar 07 2005
%o (PARI) a(n) = {my(f = factor(n), k = gcd(f[,2])); (sqrtnint(n, k+1) + 1)^(k + 1) - n} \\ _David A. Corneth_, Sep 24 2023
%Y Cf. A052409.
%K nonn
%O 1,2
%A _Amarnath Murthy_, Jul 26 2003
%E More terms from _David Wasserman_, Mar 07 2005
%E Offset corrected by _David A. Corneth_, Sep 24 2023