4 ms·
Huh, neat. I just read about this after seeing it as an example in UPenn's CS 194 "Introduction to Haskell" notes. hailstone :: Integer -> Integer hailston
by odyssey7 7y ago
Huh, neat. I just read about this after seeing it as an example in UPenn's CS 194 "Introduction to Haskell" notes.
hailstone :: Integer -> Integer
hailstone n
| n `mod` 2 == 0 = n `div` 2
| otherwise = 3*n + 1
https://www.seas.upenn.edu/~cis194/spring13/lectures/01-intro.html https://www.seas.upenn.edu/~cis194/spring13/lectures/01-intr...
- errantspark 7y agoit really is fantastic how simple it is to express, i sketched in the console as i was reading the article n=>n-1?n%2?c(n/2):c(n*3+1):1
- bjoli 7y agoNow see how fast you can make it run! 22 year old me was the king of the project Euler forum for that specific problem ("find the longest sequence below 1000000") until my post got removed (which all newer posts for old problems are). Doing those stupid things actually made me learn a lot about how computers work