Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2019
177
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.05 KB | None | 0 0
  1. 7. (Textbook #13) An interesting (yet unsolved) question in mathematics is called “hailstone numbers.” This series is produced by taking an initial integer, and if the number is even, dividing it by 2. If the number is odd, multiply it by 3 and add 1. This process is then repeated. For example, an initial number of 10 produces:
  2.  
  3. 10, 5, 16, 8, 4, 2, 1, 4, 2, 1 …
  4.  
  5.  
  6. An initial number 23 produces:
  7.  
  8. 23, 70, 35, 106, 53, 160, 80, 40, 20, 10, 5, 16, 8, 4, 2, 1, 4, 2, 1, …
  9.  
  10. Note that both numbers eventually reach the 4, 2, 1, 4, 2, 1 … cycle. Create two applications (HailStone1 and HailStone2) that answer the following questions for the initial values of 1 to 200:
  11.  
  12. a) Do all integers for 1 to 200 eventually reach this cycle?
  13.  
  14. b) What is the maximum number of iterations to reach the cycle and which starting number produces this maximum?
  15.  
  16. If the integers were for 1 to 60 the output would be:
  17. After inspecting the Hailstone numbers from 1 to 60,
  18. The maximum iterations to 4,2,1 were: 111
  19. The maximum iterations occurred at: 54 55
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement