Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def factorizedGCD(a, b)
- a_result = 1
- b_result = 1
- x = 0
- smallest_number = 0
- gcd = 0
- a_array_length = a.length
- b_array_length = b.length
- while (x < a_array_length)
- a_result = a_result * a[x]
- x = x + 1
- end
- x = 0
- while (x < b_array_length)
- b_result = b_result * b[x]
- x = x + 1
- end
- x = 1
- if a_result <= b_result then
- smallest_number = a_result
- else
- smallest_number = b_result
- end
- while (x <= smallest_number)
- if (a_result % x == 0) and (b_result % x == 0) then
- gcd = x
- end
- x = x + 1
- end
- return gcd
- end
Advertisement
Add Comment
Please, Sign In to add comment