All pastes #1345304 Raw Edit

ergasthrio

public text v1 · immutable
#1345304 ·published 2009-02-23 22:40 UTC
rendered paste body
import Prelude

gcd2 a b =
  if b == 1 then 1 else
    let rest = a `mod` b
  in
    if rest == 0 then b else gcd2 b rest
           

fun n i acc
  | i == n = acc+1
  | gcd i n /= 1 = fun n (i+1) (acc+1)
  | otherwise = fun n (i+1) acc

--ask n = fun n 1 0

main = putStrLn $ show $ fun 3000000 1 0