OFFSET
1,2
COMMENTS
All practical numbers are terms of this sequence.
Referred to as "semi-practical" numbers in the comments of the linked Numberphile video.
LINKS
Alois P. Heinz, Table of n, a(n) for n = 1..10000
James Grime, Practical Numbers, Numberphile video (2023).
MAPLE
q:= proc(n) uses numtheory, ListTools; local b, l, s;
l:= [divisors(n)[]]; s:= PartialSums(l);
b:= proc(m, i) option remember; m=0 or i>0 and m<=s[i] and
(b(m, i-1) or b(abs(m-l[i]), i-1) or b(m+l[i], i-1))
end;
andmap(x-> b(x, nops(l)), [$1..n])
end:
select(q, [$1..256])[]; # Alois P. Heinz, May 23 2023
MATHEMATICA
q[n_] := Module[{b, l, s}, l = Divisors[n]; s = Accumulate[l]; b[m_, i_] := b[m, i] = m == 0 || i > 0 && m <= s[[i]] && (b[m, i-1] || b[Abs[m - l[[i]]], i-1] || b[m+l[[i]], i-1]); AllTrue[Range[n], b[#, Length[l]]&]];
Select[Range[256], q] (* Jean-François Alcover, Nov 12 2023, after Alois P. Heinz *)
PROG
(Python)
import math
def divisorGenerator(n):
large_divisors = []
for i in range(1, int(math.sqrt(n) + 1)):
if n % i == 0:
yield i
if i*i != n:
large_divisors.append(int(n / i))
for divisor in reversed(large_divisors):
yield divisor
from itertools import chain, combinations
def all_combinations(iterable, n):
s = list(iterable)
for sumset in chain.from_iterable(combinations(s, r) for r in range(len(s)+1)):
remaining = list(set(s).symmetric_difference(set(list(sumset))))
for subtractset in chain.from_iterable(combinations(remaining, r) for r in range(len(remaining)+1)):
value = sum(list(sumset))-sum(list(subtractset))
if value>0 and value<=n:
yield value
def is_A363227(n):
return len(set(all_combinations(divisorGenerator(n), n)))==n
max_n = 250
print([x for x in range(max_n+1) if is_A363227(x)])
(Python)
from itertools import count, islice
from sympy import divisors
def A363227_gen(startvalue=1): # generator of terms >= startvalue
for m in count(max(startvalue, 1)):
c = {0}
for d in divisors(m, generator=True):
c |= {a+d for a in c}|{a-d for a in c}
if all(k in c for k in range(1, m+1)):
yield m
CROSSREFS
KEYWORD
nonn
AUTHOR
Guy Ziv, May 21 2023
STATUS
approved