K
kathy
if:
1. s[n]=2*S[n-1]
2. s[0]=2
then:
s[n]=?
1. s[n]=2*S[n-1]
2. s[0]=2
then:
s[n]=?
-----Original Message-----
if:
1. s[n]=2*S[n-1]
2. s[0]=2
then:
s[n]=?
.
kathy said:if:
1. s[n]=2*S[n-1]
2. s[0]=2
then:
s[n]=?
GC said:s[n]=2^(n+1)-1
Jon Skeet said:GC said:s[n]=2^(n+1)-1
No it doesn't.
s[0]=2
s[1]=3
s[2]=5
s[3]=9
s[4]=17
s[5]=33
Your sequence would go:
s[0]=1 // Disagreement even on the axioms!
s[1]=3
s[2]=7
s[3]=15
s[4]=31
s[5]=63
-----Original Message-----
Given you say algorithm maybe your assignment expects an answer something
along the lines of,
function int S(int n)
{
if (n==0)
return 2;
else
return 2 * S(n - 1) - 1;
}
Why don't you just tell us exactly what the questions are and we'll get you
an A+.
kathy said:correction:
if:
1. s[n]=2*S[n-1]-1
2. s[0]=2
then:
s[n]=?
.