We use cookies to ensure you have the best browsing experience on our website. Please read our cookie policy for more information about how we use cookies.
My OCaml code works fine with the first 3 TC, but on #3 it starts to break...
First I get a list of prime factors, I generate a Set of factors and intersect them with each other so the (Prime, Exponent) lists can have the same length and items.
Then I count each number in the common set and make a List of (Prime, Exponent).
Last, I get the least Exponent and multiply to get the total number and apply the modulo operation.
The result given in the output is a negative number, so I guess I ran out of Int64 values while multiplying...
I'm running into a lot of timeout/memory issues with these kinds of exercises and OCaml, should I be using another language?
Cookie support is required to access HackerRank
Seems like cookies are disabled on this browser, please enable them to open this website
Huge GCD
You are viewing a single comment's thread. Return to all comments →
My OCaml code works fine with the first 3 TC, but on #3 it starts to break... First I get a list of prime factors, I generate a Set of factors and intersect them with each other so the (Prime, Exponent) lists can have the same length and items. Then I count each number in the common set and make a List of (Prime, Exponent). Last, I get the least Exponent and multiply to get the total number and apply the modulo operation.
The result given in the output is a negative number, so I guess I ran out of Int64 values while multiplying...
I'm running into a lot of timeout/memory issues with these kinds of exercises and OCaml, should I be using another language?