473,320 Members | 1,872 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,320 software developers and data experts.

algorithm?

if:
1. s[n]=2*S[n-1]
2. s[0]=2
then:
s[n]=?
Nov 15 '05 #1
14 1135
2 ^ n+1
"kathy" <ka***@nospam.com> wrote in message
news:05****************************@phx.gbl...
if:
1. s[n]=2*S[n-1]
2. s[0]=2
then:
s[n]=?

Nov 15 '05 #2
if you want that to be recursive for 2^n then make s[0] = 1 otherwise its
2^(n+1)
"kathy" <ka***@nospam.com> wrote in message
news:05****************************@phx.gbl...
if:
1. s[n]=2*S[n-1]
2. s[0]=2
then:
s[n]=?

Nov 15 '05 #3
-----Original Message-----
if:
1. s[n]=2*S[n-1]
2. s[0]=2
then:
s[n]=?
.


s[n] = 2 ^ n+1 (2 raise to the power n+1)
Nov 15 '05 #4
GC
s[n]=2^(n+1)

-----Original Message-----
if:
1. s[n]=2*S[n-1]
2. s[0]=2
then:
s[n]=?
.

Nov 15 '05 #5
kathy <ka***@nospam.com> wrote:
if:
1. s[n]=2*S[n-1]
2. s[0]=2
then:
s[n]=?


s[n]=2^(n+1) (for all n>=0)

However, what's that got to do with C#?

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 15 '05 #6
correction:
if:
1. s[n]=2*S[n-1]-1
2. s[0]=2
then:
s[n]=?

Nov 15 '05 #7
GC
s[n]=2^(n+1)-1

come on now...
-----Original Message-----
correction:
if:
1. s[n]=2*S[n-1]-1
2. s[0]=2
then:
s[n]=?

.

Nov 15 '05 #8
s[n] is (2^n) + 1
series looks like: 2, 3, 5, 9, 17, 33, 65, 129, ...

What's the point?

"kathy" <ka***@nospam.com> a écrit dans le message de
news:05****************************@phx.gbl...
correction:
if:
1. s[n]=2*S[n-1]-1
2. s[0]=2
then:
s[n]=?

Nov 15 '05 #9
GC <gc********@yahoo.com> wrote:
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

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too
Nov 15 '05 #10
GC
Ok, I am being dumb today. Tomorrow I will be smart again.
"Jon Skeet" <sk***@pobox.com> wrote in message
news:MP************************@news.microsoft.com ...
GC <gc********@yahoo.com> wrote:
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

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet/
If replying to the group, please do not mail me too

Nov 15 '05 #11
Hi Kathy, Jon,

You've got me puzzled. My question is: What's this got to do with
<anything> ?

Regards,
Fergus
Nov 15 '05 #12
Hi,

s[n] = a big error 'cause when n=0, (n-1) will be an invalid index into s.
Unless of course you reorder your statements and correctly setup your loop.

Is this a programming group or what?

Pete

kathy wrote:
correction:
if:
1. s[n]=2*S[n-1]-1
2. s[0]=2
then:
s[n]=?

Nov 15 '05 #13
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" <ka***@nospam.com> wrote in message
news:05****************************@phx.gbl...
correction:
if:
1. s[n]=2*S[n-1]-1
2. s[0]=2
then:
s[n]=?

Nov 15 '05 #14
s[n] = (2^n) + 1;
-----Original Message-----
Given you say algorithm maybe your assignment expects an answer somethingalong 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 youan A+.
"kathy" <ka***@nospam.com> wrote in message
news:05****************************@phx.gbl...
correction:
if:
1. s[n]=2*S[n-1]-1
2. s[0]=2
then:
s[n]=?

.

Nov 15 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Jack Smith | last post by:
Hello, any help appreciated with following problem. I figured out the algorithm (I think), just having trouble proving it is optimal. Suppose we are given n tasks each of which takes 1 unit...
16
by: cody | last post by:
I have to write an algorithm with must ensure that objects are put in buckets (which are always 4 in size). The objects have two properties: A and B. It is not allowed that in a bucket are objects...
10
by: bpontius | last post by:
The GES Algorithm A Surprisingly Simple Algorithm for Parallel Pattern Matching "Partially because the best algorithms presented in the literature are difficult to understand and to implement,...
32
by: Cmorriskuerten | last post by:
HI, is this is this solution to test if a number is a prime number or not: /* * Is n a prime number? * Return TRUE (1): n is a prime number * Return FALSE (0): n is a *not* a prime number...
2
by: ben | last post by:
hello, i'm following an algorithm book and am stuck on an early excersise in it, not because of the c programming side of it or even the algorithm side of it, i don't think, but because of maths....
113
by: Bonj | last post by:
I was in need of an encryption algorithm to the following requirements: 1) Must be capable of encrypting strings to a byte array, and decyrpting back again to the same string 2) Must have the same...
4
by: FBM | last post by:
Hi, I am working on a program that simulates one of the elements of ATM. The simulation stores events which occurs every some milliseconds for a certain amount of time. Every time that an event...
2
by: Julio C. Hernandez Castro | last post by:
Dear all, We have just developped a new block cipher called Raiden, following a Feistel Network structure by means of genetic programming. Our intention now consists on getting as much feedback...
0
by: aruna | last post by:
hey guys i earlier had very valuable responses from you all for base64 encoding algorithm.so thank for that. so now i need your assistance to do a float encoding algorithm. you may wonder why i'm...
1
by: almurph | last post by:
Hi everyone, Concerning the Needleman-Wunsch algorithm (cf. http://en.wikipedia.org/wiki/Needleman-Wunsch_algorithm) I have noticed a possible loop. Inside the algorithm there is an...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
0
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.