
-----------------------------------
5pretty
Sun Apr 27, 2014 7:01 pm

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



Post any relevant code (You may choose to attach the file instead of posting the code if it is too long)








Please specify what version of Turing you are using


-----------------------------------
Insectoid
Sun Apr 27, 2014 7:11 pm

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
Sun Apr 27, 2014 7:14 pm

Re: How to find the multiples in Turing?
-----------------------------------
for i: 60..160 by 4
put i
end for

like that?

-----------------------------------
Insectoid
Sun Apr 27, 2014 7:30 pm

RE:How to find the multiples in Turing?
-----------------------------------
Did you try it?

-----------------------------------
5pretty
Sun Apr 27, 2014 7:42 pm

Re: How to find the multiples in Turing?
-----------------------------------
Yes I tried it and I got numbers starting from 68 by 4s until 160...

-----------------------------------
Dreadnought
Sun Apr 27, 2014 8:15 pm

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 [tdoc]View.Set[/tdoc].

-----------------------------------
5pretty
Sun Apr 27, 2014 8:19 pm

Re: How to find the multiples in Turing?
-----------------------------------
But how do I come up with the code first? Multiplies of 4s

-----------------------------------
Insectoid
Sun Apr 27, 2014 8:26 pm

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.

-----------------------------------
5pretty
Sun Apr 27, 2014 8:31 pm

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
Sun Apr 27, 2014 10:03 pm

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
Sun Apr 27, 2014 10:26 pm

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?
