a(n) = (n-1)! * Sum_{k=0..n-2} n^k/k!
and the approximate form shows it's grows roughly as n^n: a(n) ~ sqrt(Pi/2)*n^(n-1/2)
Here's my Python implementation: from math import factorial
from fractions import Fraction as F
def A000435(n):
return int(factorial(n-1) *
sum(F(n**k, factorial(k)) for k in range(0, n-1)))
The video you linked to is on OEIS at https://oeis.org/A000127 and is a quartic: def A000127(n):
return (n**4 - 6*n**3 + 23*n**2 - 18*n + 24)//24If we think about a polynomial, say 3x^2 + 2x + 1 -- then that's basically an algorithm that says "take x, raise it to the second power, muliply it by 3, take the result of that, add it to x multiplied by 2, and then take the result of that, and add one to it".
In other words, in that algorithmic definition,
a) There is no recursion
(note that factorials imply recursion in an algorithm -- even though they could be computed by using a simple look-up table)
and,
b) There is no division
(which could result in non-integer values)
So, in the formulas you give, you are using both recursion and division to form your sequences.
OK, so number tables / triangles / fans (call them what you will) -- don't work for things like that.
I am willing to buy into that, prima facie, but "with the proverbial grain of salt"...
You see, there's something deeper about math -- that we're not understanding here...
To understand what it is or may be (I don't know what it is, all that follows is mathematically speculative reasoning, and might be wrong, might be quite wrong indeed!), then I would suggest the following:
First, consider the Fibonnaci Sequence: https://oeis.org/A000045
Why?
Because this is the simplest (AFAIK) recurrence relationship (AKA recursive, "defined using recursion") integer sequence -- that can be produced.
To recap, its definition is:
F(n) = F(n-1) + F(n-2)
(with F(0) = 0 and F(1) = 1)
Now let's create that integer sequence -- and a corresponding number table / difference table / triangle / fan (again, call it what you will) -- and let's see if that works...
Now, I don't have Python all set up to do this -- all I have is pen and paper.
But I tried it -- and lo and behold, it works!
What's very interesting about the Fibonnaci Sequence -- is that if you create a number table for it -- you'll see that it repeats (although each row is shifted to the right!) in descending rows!
In other words, that number table -- if we can spot that pattern -- is in fact showing us the recurrence/recursive relationship!
In other words, it's still working(!) -- for this simple recurrence/recursive formula!
But we know that it fails -- somewhere between this simple recurrence algorithm -- and the one you have presented!
My challenge to you then, as a fellow Mathematician (I haven't done this by the way, I'm lazy! <g>) -- is to figure out when/where/why the number table / difference table / triangle / fan -- fails -- between the simplest of all recurrence relationship formula, the Fibonnaci sequence -- and this one!
Because you see, I'll bet there's some interesting mathematical knowledge there!.
I'd do it myself -- but no time!
Besides, you have Python already set up and running and everything... I don't!
Anyway, I think it would be interesting to know this!
Also -- once the exact failure criteria are understood -- next question is, is it possible to construct an n-dimensional table (like maybe 2 or more interlinked/interrelated number/difference tables) -- where one maps to others, and you can get the correct answer for deeply recursive algorithms -- which include division?
Yes, factorials can be defined through recursion. But so can multiplication of non-negative integers:
def mult(a, b):
if a == 0 or b == 0: return 0
if a == 1: return b
return mult(a-1, b) + b
>>> mult(5, 9)
45
Furthermore, factorials can alternatively be defined through the Gamma function, which supports more than just the integers and isn't defined recursively. https://en.wikipedia.org/wiki/Gamma_function .> the simplest (AFAIK) recurrence relationship ...that can be produced.
The positive integers is even easier. For n >= 0:
F(0) = 0
F(n) = 1 + F(n-1)
> What's very interesting about the Fibonnaci SequenceAnother interesting thing about the Fibonnaci Sequence is that it has a closed-form solution, given in your OEIS link as:
F(n) = ((1+sqrt(5))^n - (1-sqrt(5))^n)/(2^n*sqrt(5))
or see https://en.wikipedia.org/wiki/Fibonacci_number#Closed-form_e... .It is also non-polynomial. In the limit, it approaches a simple exponential.
Nor is it bounded by a polynomial, meaning that if you pick any positive integer p and any constant C, and define g(n) = C n^p then for a large enough n you will find that |g(n)| < |F(n)| .
Furthermore, A000435 , with its n^n - like form, grow even faster than exponential. It's similar to factorial growth.
> as a fellow Mathematician
I am not a mathematician. Neither are you.
> s to figure out when/where/why the number table / difference table / triangle / fan -- fails -- between the simplest of all recurrence relationship formula, the Fibonnaci sequence -- and this one
Consider f(n) = f(n-1) + 1 where f(0) = 0. This is the sequence 0, 1, 2, 3, .... This addition of 1 can be seen trivially in the difference table.
Consider f(n) = f(n-1) + f(n-1) with f(1) = 1. This is the sequence 1, 2, 4, 8, 16, 32, or 2^n, which is an exponential function.
Consider the Fibonacci function f(n) = f(n-1) + f(n-2) with f(1) = f(2) = 1. This uses an addition of the two previous numbers. It approaches an exponential function as n gets larger.
Consider f(n) = n * f(n-1) with f(1) = 1 This is the factorial. It grows faster than the exponential function.
Because the last one uses a multiplication instead of addition, a difference table (which is based on subtraction) won't show the pattern. The inverse of multiplication is division, so use a division table.
> deeply recursive algorithms
These are not deeply recursive. For an example of those, see the Ackermann function. https://en.wikipedia.org/wiki/Ackermann_function , which is not primitive recursive like functions we've discussed so far.