Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Co-prime drill
- function gcd(x::Integer, y::Integer)
- while (x > 0) && (y > 0)
- if x < y
- y = y % x
- else
- x = x % y
- end
- end
- return max(x, y)
- end
- AreCoprime(x::Integer, y::Integer) = (gcd(x, y) == 1)
- function main(n_max::Integer)
- x = 9 # n = 0
- y = 10 # n = 1
- for n = BigInt.(2:n_max)
- n % 50000 == 0 && println(n)
- x = y
- y = n^17 + 9
- if !AreCoprime(x, y)
- println("Rule breaks at n = ", n, " as ", x, " and ", y, " are not coprime!")
- return
- end
- end
- println("\nAll cases up to n = ", n_max, " were coprimes...")
- end
Add Comment
Please, Sign In to add comment