Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 im lost can someone help me plzz
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
kid105




PostPosted: Wed Jan 13, 2010 9:09 pm   Post subject: im lost can someone help me plzz

What is it you are trying to achieve?

1, 1, 2, 3, 5, 8, 13, 21, 34, . . .
write a program which generates the first n terms of this sequence, where the value of n is entered by the user, given the first two terms of the sequence. cuccessive terms are to be stored in an array.


What is the problem you are having?
im kind of stuck on this one i keep getting errors.


Describe what you have tried to solve this problem
i have written this program below.


Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)
<Answer Here>

Turing:


var number : array 1 .. 10 of int
var sum := 0
put skip
for counter : 1 .. 10
    put "Enter number ", counter, ": " ..
    get number (counter)
end for
put skip
put "The ten numbers in order of entry are: "
put skip
for counter : 1 .. 10
    put number (counter) : 5 ..
end for
for counter : 1 .. 10
    sum := sum + number (counter)
    put sum
end for



Please specify what version of Turing you are using
<Answer Here>
Sponsor
Sponsor
Sponsor
sponsor
Turing_Gamer




PostPosted: Wed Jan 13, 2010 10:36 pm   Post subject: Re: im lost can someone help me plzz

You may need and intstr command for the following
Turing:

for counter : 1 .. 10
    put intstr (number (counter))
end for
for counter : 1 .. 10
    sum := sum + number (counter)
    put intstr (sum)
end for
Euphoracle




PostPosted: Wed Jan 13, 2010 10:43 pm   Post subject: RE:im lost can someone help me plzz

Well, your code is not solving the problem asked. You are asked to input one number value from the user (a natural number to be precise) and complete the sequence to that many numbers, we'll call that n.

Now, if you analyze the sequence, you may notice the following pattern:

Consider the sequence carefully,

{1, 1, 2, 3, 5, 8, ...}

You are given the first two numbers (1 and 1). How can you get 2 from 1 and 1?
How can you get 3 from 1 and 2?
How can you get 5 from 2 and 3?

That's your pattern.

Your program should take as input n which is an int and output this sequence to n terms.

You can generate the next term using the previous two terms using the pattern from above. You should do this for n terms.
Display posts from previous:   
   Index -> Programming, Turing -> Turing Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 3 Posts ]
Jump to:   


Style:  
Search: