OFFSET
1,1
COMMENTS
Terms are all even because b^r - b^s == b - b == 0 (mod 2).
From David A. Corneth, Apr 26 2025: (Start)
By definition, b, s, r and b^r - b^s is positive. Therefore, r > s. If b = 1 then b^r - b^s = 1^r - 1^s = 0 which is excluded by default so b > 1. Suppose we look for terms <= U. Then b is maximal when (s, r) = (1, 2) i.e. b^2 - b <= U. Solving for b gives (sqrt(4*U + 1) + 1) / 2.
As r > s >= 1, r >= 2.
Once b is fixed, b^r - b^s is minimal when s = r-1, enabling the largest r.
So we'd have b^r - b^(r-1) = (b - 1)*(b^(r-1)) <= U. Solving for r gives r <= log(U / (b - 1)) / log(b) + 1.
Once b and r are fixed we have
b^r - b^s <= U so b^r - U <= b^s. Solving for s gives log(b^r - U) / log(b) <= s.
Summarizing we have
2 <= b <= (sqrt(4*U + 1) + 1) / 2,
2 <= r <= log(U / (b - 1)) / log(b) + 1,
log(b^r - U) / log(b) <= s <= r-1. (End)
LINKS
Karl-Heinz Hofmann, Table of n, a(n) for n = 1..10000
EXAMPLE
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.
PROG
(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
(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
CROSSREFS
KEYWORD
nonn
AUTHOR
Boas Bakker, Apr 13 2025
STATUS
approved
