Let be the number of ways the first natural numbers, from to , can be ordered such that every number in the permutation divides the sum of the previous numbers.
Find
[4, 1, 5, 2, 6, 3]
This section requires Javascript.
You are seeing this because something didn't load right. We suggest you, (a) try
refreshing the page, (b) enabling javascript if it is disabled on your browser and,
finally, (c)
loading the
non-javascript version of this page
. We're sorry about the hassle.
Permuting the numbers first and then looking for the solutions would be very expensive for large numbers. For 19, there are 1 9 ! or 121645100408832000 possible permutations. For 30, it would be 3 0 ! or about 2 . 6 × 1 0 3 2 . It will takes years for a computer to compute the answer.
To deal with this, instead looking in permutation, I generated sequences by strictly following the given rules. Here is the mechanism -
Takes about 0.5s.
However, 30 is a very big target. The time increases exponentially (with a few exceptions) with each step. Here are results on my machine -
(OLD TABLE)
f(20) = 1319, time = 1.6s
f(21) = 5320, time = 3.6s
f(22) = 3220, time = 9.5s
f(23) = 4489, time = 13s
f(24) = 20237, time = 53s
f(25) = 36580, time = 139s
f(26) = 52875, time = 254s
f(27) = 197103, time = 660s
f(28) = 216562, time = 2557s
EDIT
Here's a small modification which halves the time consumed -
Takes about 0.2s
f(25) = 33s