Author |
Message |
5pretty
|
Posted: 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
|
|
|
Insectoid
|
Posted: 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
|
Posted: 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
|
Posted: Sun Apr 27, 2014 7:30 pm Post subject: RE:How to find the multiples in Turing? |
|
|
Did you try it? |
|
|
|
|
|
5pretty
|
Posted: 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
|
Posted: 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
|
Posted: 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
|
Posted: 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
|
|
|
5pretty
|
Posted: 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
|
Posted: 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
|
Posted: 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? |
|
|
|
|
|
|