Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

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-intr...


Now 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


it 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




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: