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.
- Prepare
- Functional Programming
- Ad Hoc
- Huge GCD
- Discussions
Huge GCD
Huge GCD
Sort by
recency
|
13 Discussions
|
Please Login in order to post a comment
haskell
Haskell:
One-liner in Haskell (no focus on performance though):
Scala solution:
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?