Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- function gcd(x::Int64, y::Int64)
- while (x > 0) && (y > 0)
- if x < y
- y = y % x
- else
- x = x % y
- end
- end
- return max(x, y)
- end
- AreCoprime(x::Int64, y::Int64) = (gcd(x, y) == 1)
- function main(lo::Int64, hi::Int64)
- lo, hi = minmax(lo, hi)
- if (lo > 1e18) || (hi > 1e18) || (hi - lo > 50); error("lo and hi parameters are invalid!"); end
- for x = lo:(hi-2)
- for y = (x+1):(hi-1)
- if AreCoprime(x, y)
- for z = (y+1):hi
- if AreCoprime(y, z) && !AreCoprime(x, z); return (x, y, z); end
- end
- end
- end
- end
- return (NaN, NaN, NaN)
- end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement