P
PTS
Can someone help me write recursive function from the following
sequence....
1,3,5,11,21,43...
Thanks for your help!
sequence....
1,3,5,11,21,43...
Thanks for your help!
PTS said:Can someone help me write recursive function from the following
sequence....
1,3,5,11,21,43...
Have you tried to define first which is the law of that series?PTS said:Can someone help me write recursive function from the following
sequence....
1,3,5,11,21,43...
Thanks for your help!
PTS said:Can someone help me write recursive function from the following
sequence....
1,3,5,11,21,43...
Thanks for your help!
PTS said:I have tried, and came up with two base cases, which equal n-1, and
n-2. This sequence has no relation. That is the problem I am having
with understanding this. It is not easy to me which I why I am on here
trying to get the understanding from someone that will be able to give
me some help and/or advice. Some guidance is what I am asking.
Karl said:1 3 5 11 21 43
3 = 2 * 1 + 1
5 = 2 * 3 - 1
11 = 2 * 5 + 1
21 = 2 * 11 - 1
43 = 2 * 21 + 1
Does that help ?
PTS said:I have tried, and came up with two base cases, which equal n-1, and
n-2. This sequence has no relation. That is the problem I am having
with understanding this. It is not easy to me which I why I am on here
trying to get the understanding from someone that will be able to give
me some help and/or advice. Some guidance is what I am asking.
PTS said:I have tried, and came up with two base cases, which equal n-1, and
n-2. This sequence has no relation.
That is the problem I am having
with understanding this. It is not easy to me which I why I am on here
trying to get the understanding from someone that will be able to give
me some help and/or advice. Some guidance is what I am asking.
Dan said:sequence: 1 3 5 11 21 43 represents the values of the plynomial
function
g(x) = a*x^5 + b*x^4 + c*x^3 + d*x^2 + e*x + f
where:
g(0) = 1
g(1) = 3
g(2) = 5
g(3) = 11
g(4) = 21
g(5) = 43
replace in the function above and you will get a linear system of
equationd with the unknowns a, b, c, d, e, f solve it and you get
a = 1/10
b = -7/6
c = 31/6
d = -53/6
e = 101/15
f = 1
now you can calculate the values of g(x) for any x
do a for loop.
dan
Victor Bazarov said:Karl said:1 3 5 11 21 43
3 = 2 * 1 + 1
5 = 2 * 3 - 1
11 = 2 * 5 + 1
21 = 2 * 11 - 1
43 = 2 * 21 + 1
Does that help ?
Actually it seems that the sequence is simpler (confirmed by the page
suggested by 'red floyd'):
5 = 3 + 2 * 1
11 = 5 + 2 * 3
21 = 11 + 2 * 5
43 = 21 + 2 * 11
I suppose the true sequence begins with
0 1 1 3 5 11 ...
(assuming that [ 0 1 ] is the beginning of many sequences)
V
the sequence is
N0 = 1
N1 = 3 = 1 + (add 2)
N2 = 5 = 3 + 1 + (add 1)
N3 = 11 = 5 + 3 + 1 +(add 2)
N4 = 21 = 11 + 5 + 3 + (add 1)
N5 = 43 = 21 + 11 + 5 + 3 + 1 + (add 2)
its simlpe the sum of the preceding values plus either 1 or 2
depending on whether N is even or odd.
Greg said:If C is the current number in the series, the next number in the
series, D, is calculated by adding 2 x B (C's predecessor) to C. In
other words:
D = C + B * 2
Here is the solution in code:
Want to reply to this thread or ask your own question?
You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.