Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def greatestCommonPrimeDivisor(a, b)
- x = 1
- largest_prime = -1
- min = 0
- y = 1
- prime = false
- if a <= b then
- min = a
- else
- min = b
- end
- while (x <= min)
- if a % x == 0 and b % x == 0 then
- while (y <= x)
- if x % y != 0 and y != 1 and x != y then
- prime = true
- end
- if x % y == 0 and y != 1 and x != y then
- prime = false
- break
- end
- y = y + 1
- end
- if prime == true then
- largest_prime = x
- end
- end
- prime = false
- y = 1
- x = x + 1
- end
- return largest_prime
- end
Advertisement
Add Comment
Please, Sign In to add comment