login
The OEIS is supported by the many generous donors to the OEIS Foundation.

 

Logo
Hints
(Greetings from The On-Line Encyclopedia of Integer Sequences!)
A258097 Number of nonnegative integers that can be computed using exactly n n's and the four basic arithmetic operations {+, -, *, /}. 11
1, 3, 9, 26, 68, 198, 536, 1660, 4769, 15945, 46240, 165732, 488268, 1848866, 5852344 (list; graph; refs; listen; history; text; internal format)
OFFSET
1,2
LINKS
MAPLE
a:= proc(n) option remember; local f; f:=
proc(m) option remember; `if`(m=1, {n}, {
seq(seq(seq([x+y, x-y, x*y, `if`(y=0, [][], x/y)
][], y=f(m-j)), x=f(j)), j=1..m-1)})
end; forget(f);
nops([select(z->z>=0 and is(z, integer), f(n))[]])
end:
seq(a(n), n=1..9);
MATHEMATICA
a[n_] := a[n] = Module[{f}, f[m_] := f[m] = If[m == 1, {n},
Union@ Flatten@ Table[Table[Table[{x + y, x - y, x*y,
If[y == 0, Nothing, x/y]}, {y, f[m-j]}], {x, f[j]}], {j, m-1}]];
Length[Select[f[n], # >= 0 && IntegerQ[#]&]]];
Table[a[n], {n, 1, 9}] (* Jean-François Alcover, Aug 29 2021, after Alois P. Heinz *)
PROG
(Python)
from fractions import Fraction
from functools import lru_cache
def a(n):
@lru_cache()
def f(m):
if m == 1: return {Fraction(n, 1)}
out = set()
for j in range(1, m):
for x in f(j):
for y in f(m-j):
out.update([x + y, x - y, x * y])
if y: out.add(Fraction(x, y))
return list(out)
return sum(num >= 0 and num.denominator == 1 for num in f(n))
print([a(n) for n in range(1, 10)]) # Michael S. Branicky, Aug 29 2021 after Alois P. Heinz
CROSSREFS
Sequence in context: A035313 A055293 A034531 * A221946 A291410 A048470
KEYWORD
nonn,more
AUTHOR
Alois P. Heinz, May 19 2015
EXTENSIONS
a(13)-a(14) from Giovanni Resta, May 20 2015
a(15) from Michael S. Branicky, Aug 29 2021
STATUS
approved

Lookup | Welcome | Wiki | Register | Music | Plot 2 | Demos | Index | Browse | More | WebCam
Contribute new seq. or comment | Format | Style Sheet | Transforms | Superseeker | Recents
The OEIS Community | Maintained by The OEIS Foundation Inc.

License Agreements, Terms of Use, Privacy Policy. .

Last modified April 19 21:09 EDT 2024. Contains 371798 sequences. (Running on oeis4.)