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

Username:   Password: 
 RegisterRegister   
 How to find the multiples in Turing?
Index -> Programming, Turing -> Turing Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
5pretty




PostPosted: Sun Apr 27, 2014 7:01 pm   Post subject: How to find the multiples in Turing?

What is it you are trying to achieve?
How to find the multiples of 4 between 60 and 160 using for loops.


What is the problem you are having?
Having difficulties coming up with the code


Describe what you have tried to solve this problem
<Answer Here>


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

Turing:


<Add your code here>



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




PostPosted: Sun Apr 27, 2014 7:11 pm   Post subject: RE:How to find the multiples in Turing?

For loops can skip numbers. For example, 'for i : 0..100 by 2' will only iterate over even numbers. It counts by 2's. Think you can take advantage of this to solve the problem?
5pretty




PostPosted: Sun Apr 27, 2014 7:14 pm   Post subject: Re: How to find the multiples in Turing?

for i: 60..160 by 4
put i
end for

like that?
Insectoid




PostPosted: Sun Apr 27, 2014 7:30 pm   Post subject: RE:How to find the multiples in Turing?

Did you try it?
5pretty




PostPosted: Sun Apr 27, 2014 7:42 pm   Post subject: Re: How to find the multiples in Turing?

Yes I tried it and I got numbers starting from 68 by 4s until 160...
Dreadnought




PostPosted: Sun Apr 27, 2014 8:15 pm   Post subject: Re: How to find the multiples in Turing?

The top lines got erased because there are too many lines to show.

You could avoid using a new line for each number or change the view settings with View.Set.
5pretty




PostPosted: Sun Apr 27, 2014 8:19 pm   Post subject: Re: How to find the multiples in Turing?

But how do I come up with the code first? Multiplies of 4s
Insectoid




PostPosted: Sun Apr 27, 2014 8:26 pm   Post subject: RE:How to find the multiples in Turing?

It's been a while, but I think View.Set ("text") will give you a scroll bar so you can see all of the numbers.
Sponsor
Sponsor
Sponsor
sponsor
5pretty




PostPosted: Sun Apr 27, 2014 8:31 pm   Post subject: Re: How to find the multiples in Turing?

but is

for i: 60..160 by 4
put i
end for

correct to find the multiples in the first place?
Dreadnought




PostPosted: Sun Apr 27, 2014 10:03 pm   Post subject: Re: How to find the multiples in Turing?

Try adding View.Set("text") to the top of your program like insectoid suggests and see what happens.
Insectoid




PostPosted: Sun Apr 27, 2014 10:26 pm   Post subject: RE:How to find the multiples in Turing?

You can easily verify by hand if the numbers it gives you are correct. How will you ever know if the algorithm is correct if you don't even know what the correct values are?
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  [ 11 Posts ]
Jump to:   


Style:  
Search: