Mo réiteach féin do uimhir a trí:
factors n = [m | m <- [1,2..floor(sqrt(fromIntegral n))], n `mod` m == 0]
prime n = null [m | m <- factors n, m > 1, m /= n]
primeFactors n = [m | m <- factors n, prime m]
main = print ( last ( primeFactors 600851475143 ) )
Tá mé réasúnta sásta leis. Ar dtús, bhí an chéad sraith 1..n, ach tar éis cúig bomaite, níor tháinig an freagra! Ansin, stad mé an sraith ag fréamh chearnach n, agus fuair mé an freagra gan mhoill.
If you're wondering what this is all about, here's the first post in this series.
No comments:
Post a Comment