A383038 Positive integers which can be expressed in the form b^r - b^s where b, r, and s are positive integers.
2, 4, 6, 8, 12, 14, 16, 18, 20, 24, 28, 30, 32, 42, 48, 54, 56, 60, 62, 64, 72, 78, 90, 96, 100, 110, 112, 120, 124, 126, 128, 132, 156, 162, 180, 182, 192, 210, 216, 224, 234, 240, 248, 252, 254, 256, 272, 294, 306, 336, 342, 380, 384, 420, 448, 462, 480, 486, 496, 500
Offset: 1
Keywords
Examples
a(6) = 14 = 16 - 2 = 2^4 - 2^1. a(9) = 20 = 25 - 5 = 5^2 - 5^1. As _David A. Corneth_ said, we know r > s > 0 and b > 1, so r > 1, and the smallest value of b is 2. So b^r - b^s >= b^(r-1) >= 2^(r-1). So to prove 10 is not in the sequence, we only need to check up up to r=4, because for r=5, 2^(s-1) = 2^4 = 16 > 10. This means there are 6 combinations of (r, s) we need to check. We also know b^r - b^s == 0 (mod b) because s > 0, so we only need to check divisors of 10. So with b = 2 and s < r < 5, we get the terms {2, 4, 6, 8, 12, 14}. With b=5 the smallest term is 5^2 - 5^1 = 20, which is bigger than 10. For b>5, b^r - b^s >= b^2 - b > 5^2 - 5, so we don't need to check those values of b.
Links
- Karl-Heinz Hofmann, Table of n, a(n) for n = 1..10000
Crossrefs
The terms of the case b=2 are in A043569.
Programs
-
Julia
function A383038List(limit::Int) res = Set{Int}() for b in 2:floor(Int, sqrt(limit)) + 2 for r in 2:limit valr = b^(r-1) * (b-1) valr > limit && break br = b^r for s in 1:r-1 val = br - b^s val > 0 && val <= limit && push!(res, val) end end end sort(collect(res)) end println(A383038List(500)) # Peter Luschny, Aug 17 2025
-
PARI
upto(n) = {n++; my(res = List()); maxb = ceil((sqrtint(4*n + 1) + 1) / 2); for(b = 2, maxb, maxr = logint(n\(b-1), b) + 1; for(r = 2, maxr, mins = max(1, ceil(log(max(b^r - n, 1)) / log(b))); mins = min(mins, r-1); \\ min() to fix messed up rounding when b^r - n is a power of b. Also solved by increasing n by 1 initially (n++). forstep(s = r-1, mins, -1, c = b^r - b^s; listput(res, c); ); ); ); Set(res) } \\ David A. Corneth, Apr 26 2025
-
Python
from sympy import integer_nthroot aupto = 500 b_max, A383038 = (i := integer_nthroot(aupto,2))[0] + 2 - i[1], set() for b in range(2, b_max): r, s = 2, 1 while (br:=b**r) - b**s <= aupto: while s > 0 and (res := br - b**s) <= aupto: A383038.add(res); s -= 1 r += 1 s = r - 1 print(sorted(A383038)) # Karl-Heinz Hofmann, Apr 29 2025
Comments