finding general term of a sequence
I have a sequence of numbers 1,34,1136,25288,1377200,…. Now can we have a sage code that can give the n th term of this sequence..
I have a sequence of numbers 1,34,1136,25288,1377200,…. Now can we have a sage code that can give the n th term of this sequence..
Searching the numerators and denominators in the Online encyclopedia of integer sequences (OEIS):
the sequence might be un=H(n)/n! where H(n)=∑k=1..n1/k is the n-th harmonic number.
sage: def u(n):
....: return sum(1/i for i in (1 .. n))/factorial(n)
....:
sage: [u(n) for n in (1 .. 8)]
[1, 3/4, 11/36, 25/288, 137/7200, 49/14400, 121/235200, 761/11289600]
There are of course many other "natural" possibilities.
For the OP: Sage ships with the command oeis
to play with directly in the REPL, eg.
sage: oeis([1, 4, 36, 288, 7200], max_results=2)
0: A277174: a(n) = Product_{i=1..n} i*rad(i) where rad(n) = A007947(n).
1: A316297: a(n) = n! times the denominator of the n-th harmonic number H(n).
Asked: 6 years ago
Seen: 726 times
Last updated: Nov 07 '18
Please give us the formula for the n.th term of this or an other sequence, we will try to implement it in one line. Else the question is not well defined.
There is no "the nth term" for a sequence like you've given with ... . For example: 1,2,3,.... could be the sequence f(n)=n or it could be f(n)=n^3-6n^2+12n-6. There are actually an infinite number of formulas that could work here.
Of course there are infinitely many ways to continue a sequence.
One can still understand the question as "Find a reasonable guess of what this sequence might be, and give the next term for that guess".
The Online encyclopedia of integer sequences (OEIS) has a collection of such reasonable guesses.