|
|
A066409
|
|
Least positive integer not representable using exactly n 9's and the operations +-*/().
|
|
0
|
|
|
1, 2, 1, 4, 13, 22, 33, 103, 195, 381, 934, 1858, 3747, 9166, 31279
(list;
graph;
refs;
listen;
history;
text;
internal format)
|
|
|
OFFSET
|
1,2
|
|
COMMENTS
|
This sequence allows fractions as intermediate results; else, a(9) would equal 138. - Michael S. Branicky, Feb 08 2023
|
|
LINKS
|
|
|
EXAMPLE
|
a(4)=4 because 4 cannot be expressed with exactly 4 nines and the operations +-*/(). E.g. 1 = 9/9+9-9, 2 = 9/9+9/9, 3 = (9+9+9)/9, but 4 has no such representation.
138 = (((9 - (9 / ((9 + 9) + 9))) * (9 + 9)) - 9) - 9.
265 = ((((9 - (9 / (9 + 9))) + 9) + 9) * ((9 * 9) + 9)) / 9.
|
|
PROG
|
(Python)
from fractions import Fraction
from functools import lru_cache
def a(n):
@lru_cache()
def f(m):
if m == 1: return {9}
out = set()
for j in range(1, m//2+1):
for x in f(j):
for y in f(m-j):
out.update([x + y, x - y, y - x, x * y])
if y: out.add(Fraction(x, y))
if x: out.add(Fraction(y, x))
return out
k, s = 1, f(n)
while k in s: k += 1
return k
|
|
CROSSREFS
|
|
|
KEYWORD
|
more,nonn
|
|
AUTHOR
|
Joe K. Crump (joecr(AT)carolina.rr.com), Dec 24 2001
|
|
EXTENSIONS
|
Corrected by Leonhard Vogt (leonhard.vogt(AT)gmx.ch), Jan 09 2006
|
|
STATUS
|
approved
|
|
|
|