Factor-perfect numbers

Revision as of 10:19, 6 October 2022 by Wherrera (talk | contribs) (spacing)

Consider the list of factors (divisors) of an integer, such as 12. The factors of 12 are [1, 2, 3, 4, 6, 12]. Consider all sorted sequences of the factors of n such that each succeeding number in such a sequnce is a multiple of its predecessor. So, for 6, we have the factors (divisors) [1, 2, 3, 6]. The 3 unique lists of sequential multiples starting with 1 and ending with 6 that can be derived from these factors are [1, 6], [1, 2, 6], and [1, 3, 6].

Factor-perfect numbers is a draft programming task. It is not yet considered ready to be promoted as a complete task, for reasons that should be found in its talk page.


Another way to see these sequences is as an set of all the ordered factorizations of a number taken so that their product is that number (excluding 1 from the sequence). So, for 6, we would have [6], [2, 3], and [3, 2]. In this description of the sequences, we are looking at the numbers needed to multiply by, in order to generate the next element in the sequences previously listed in our first definition of the sequence type, as we described it in the preceding paragraph, above.


For example, for the factorization of 6, if the first type of sequence is [1, 6], this is generated by [6] since 1 * 6 = 6. Similarly, the first type of sequence [1, 2, 6] is generated by the second type of sequence [2, 3] because 1 * 2 = 2 and 2 * 3 = 6. Similarly, [1, 3, 6] is generated by [3, 2] because 1 * 3 = 3 and 3 * 2 = 6.


If we count the number of such sorted sequences of multiples, or ordered factorizations, and using that count find all integers `n` for which the count of such sequences equals `n`, we have re-created the sequence of the "factor-perfect" numbers (OEIS 163272).


By some convention, on its OEIS page, the factor-perfect number sequence starts with 0 rather than 1. As might be expected with a sequence involving factorization and combinations, finding factor-perfect numbers becomes more demanding on CPU time as the numbers become large.


Task
  • Show all 48 ordered sequences for each of the two methods for n = 48, which is the first non-trivial factor-perfect number.
  • Write a program to calculate and show the first 7 numbers of the factor-perfect numbers.


Stretch task
  • Calculate and show more of the subsequent numbers in the sequence.


see also

[OEIS A163272] [On the maximal order of numbers in the “factorisatio numerorum” problem]


Julia

using Primes

""" Return the factors of n, including 1, n """
function factors(n::T)::Vector{T} where T <: Integer
  sort(vec(map(prod, Iterators.product((p.^(0:m) for (p, m) in eachfactor(n))...))))
end

""" Uses the first definition and recursion to generate the sequences """
function more_multiples(to_seq, from_seq)
    onemores = [[to_seq; i] for i in from_seq if i > to_seq[end] && i % to_seq[end] == 0]
    isempty(onemores) && return Int[]
    return append!(onemores, mapreduce(seq -> more_multiples(seq, from_seq), append!, onemores))
end

listing = sort!(push!(more_multiples([1], factors(48)[begin:end-1]), [1, 48]))
println("48 sequences using first definition:")
for (i, seq) in enumerate(listing)
    print(rpad(seq, 20), i % 4 == 0 ? "\n" : "")
end

println("\n48 sequences using second definition:")
for (i, seq) in enumerate(listing)
    seq[end] != 48 && push!(seq, 48)
    seq2 = [seq[i] ÷ seq[i - 1] for i in 2:length(seq)]
    print(rpad(seq2, 20), i % 4 == 0 ? "\n" : "")
end

""" Get factorization sequence count """
count_multiple_sequences(n) = length(more_multiples([1], factors(n)[begin:end-1])) + 1

println("\nOEIS A163272: ")
for n in 0:2_400_000
    if n == 0 || count_multiple_sequences(n) == n
        print(n, ",  ")
    end
end
Output:
48 sequences using first definition:
[1, 2]              [1, 2, 4]           [1, 2, 4, 8]        [1, 2, 4, 8, 16]
[1, 2, 4, 8, 24]    [1, 2, 4, 12]       [1, 2, 4, 12, 24]   [1, 2, 4, 16]
[1, 2, 4, 24]       [1, 2, 6]           [1, 2, 6, 12]       [1, 2, 6, 12, 24]
[1, 2, 6, 24]       [1, 2, 8]           [1, 2, 8, 16]       [1, 2, 8, 24]
[1, 2, 12]          [1, 2, 12, 24]      [1, 2, 16]          [1, 2, 24]
[1, 3]              [1, 3, 6]           [1, 3, 6, 12]       [1, 3, 6, 12, 24]
[1, 3, 6, 24]       [1, 3, 12]          [1, 3, 12, 24]      [1, 3, 24]
[1, 4]              [1, 4, 8]           [1, 4, 8, 16]       [1, 4, 8, 24]
[1, 4, 12]          [1, 4, 12, 24]      [1, 4, 16]          [1, 4, 24]
[1, 6]              [1, 6, 12]          [1, 6, 12, 24]      [1, 6, 24]
[1, 8]              [1, 8, 16]          [1, 8, 24]          [1, 12]
[1, 12, 24]         [1, 16]             [1, 24]             [1, 48]

48 sequences using second definition:
[2, 24]             [2, 2, 12]          [2, 2, 2, 6]        [2, 2, 2, 2, 3]     
[2, 2, 2, 3, 2]     [2, 2, 3, 4]        [2, 2, 3, 2, 2]     [2, 2, 4, 3]
[2, 2, 6, 2]        [2, 3, 8]           [2, 3, 2, 4]        [2, 3, 2, 2, 2]
[2, 3, 4, 2]        [2, 4, 6]           [2, 4, 2, 3]        [2, 4, 3, 2]
[2, 6, 4]           [2, 6, 2, 2]        [2, 8, 3]           [2, 12, 2]
[3, 16]             [3, 2, 8]           [3, 2, 2, 4]        [3, 2, 2, 2, 2]
[3, 2, 4, 2]        [3, 4, 4]           [3, 4, 2, 2]        [3, 8, 2]
[4, 12]             [4, 2, 6]           [4, 2, 2, 3]        [4, 2, 3, 2]
[4, 3, 4]           [4, 3, 2, 2]        [4, 4, 3]           [4, 6, 2]
[6, 8]              [6, 2, 4]           [6, 2, 2, 2]        [6, 4, 2]
[8, 6]              [8, 2, 3]           [8, 3, 2]           [12, 4]
[12, 2, 2]          [16, 3]             [24, 2]             [48]

OEIS A163272:
0,  1,  48,  1280,  2496,  28672,  29808,  454656,  2342912,