- #1
d-star
- 8
- 0
I'm trying to write a program in fortran that will create a sequence of numbers (starting with a number that I input) that follow the following constraints: If the number (n) in the sequence is even, then the next number in the sequence will be n/2. If the number (n) in the sequence is odd, then the next number in the sequence is 3n+1. When the sequence reaches the number 1, the sequence terminates.
I am aware that I should first write my own code first and then try to get help from that point, but I seem to be having trouble putting it all together. I am aware that the DO, IF, and MOD(x,y) statements need to be used, but I am confused as to how to arrange them so that the given constraints will work.
Thanks!
I am aware that I should first write my own code first and then try to get help from that point, but I seem to be having trouble putting it all together. I am aware that the DO, IF, and MOD(x,y) statements need to be used, but I am confused as to how to arrange them so that the given constraints will work.
Thanks!