Advertisement
Guest User

Untitled

a guest
Oct 19th, 2018
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import Debug.Trace
  2.  
  3. --collatz 0 = 0
  4. collatz 1 = 1
  5. collatz n = if even n
  6.                 then (trace (show n) (collatz (n `div` 2)))
  7.                 else (trace (show n) (collatz (3*n+1)))
  8.  
  9. collatzAufrufe 1 = 1
  10. collatzAufrufe n = if even n
  11.                     then (1 + (collatzAufrufe (n `div` 2)))
  12.                     else (1 + (collatzAufrufe (3*n+1)))
  13.  
  14. welcheZahl 1 a = a
  15. welcheZahl i a = if ((collatzAufrufe (i-1)) >= (collatzAufrufe i)) then (welcheZahl (i-1) (a-1)) else (welcheZahl (i-1) a)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement