OFFSET
1,1
LINKS
Donovan Johnson, Table of n, a(n) for n = 1..10000
Douglas Edward Iannucci, On duplicate representations as 2^x+3^y for nonnegative integers x and y, arXiv:1907.03347 [math.NT], 2019.
FORMULA
There are log^2 x/(log 2 log 3) + O(log x) terms up to x. Bounds on the error term can be made explicit. - Charles R Greathouse IV, Oct 28 2022
MAPLE
lincom:=proc(a, b, n) local i, j, s, m; s:={}; for i from 0 to n do for j from 0 to n do m:=a^i+b^j; if m<=n then s:={op(s), m} fi od; od; lprint(sort([op(s)])); end: lincom(2, 3, 760); # Zerinvary Lajos, Feb 24 2007
MATHEMATICA
mx = 760; s = Union@ Flatten@ Table[2^i + 3^j, {i, 0, Log[2, mx]}, {j, 0, Log[3, mx - 2^i]}] (* Robert G. Wilson v, Sep 19 2012 *)
PROG
(Haskell)
import Data.Set (singleton, deleteFindMin, insert)
a004050 n = a004050_list !! (n-1)
a004050_list = f 1 $ singleton (2, 1, 1) where
f x s = if y /= x then y : f y s'' else f x s''
where s'' = insert (u * 2 + v, u * 2, v) $
insert (u + 3 * v, u, 3 * v) s'
((y, u, v), s') = deleteFindMin s
-- Reinhard Zumkeller, May 20 2015
(PARI) ispow2(n)=n>>valuation(N, 2)==1
is(n)=my(k); if(n%2, if(n<3, return(0)); for(k=0, logint(n-2, 3), if(ispow2(n-3^k), return(1))); 0, ispower(n-1, , &k); k==3 || n==2 || n==4) \\ Charles R Greathouse IV, Aug 29 2016
(Python)
def aupto(lim):
s, pow3 = set(), 1
while pow3 < lim:
for j in range((lim-pow3).bit_length()):
s.add(2**j + pow3)
pow3 *= 3
return sorted(set(s))
print(aupto(756)) # Michael S. Branicky, Jul 29 2021
CROSSREFS
KEYWORD
nonn
AUTHOR
EXTENSIONS
More terms from Sascha Kurz, Jan 02 2003
STATUS
approved