Project Euler problem 5, 6 and 7, with Haskell
Problem 5
I have solved similar questions during math test so I went with a purely brute force solution to this problem as I wanted to test how long it would take to complete.
I was a little surprised that the program didn’t crash considering how large a number it had to count up to. I’m not sure if this says more about the Haskell language or modern computers. I do know that Haskell supports Integers that can be as large as the memory space of the computer, so I feel like this might be a win for Haskell.
Solving this without programming is mostly an exercise in taking the prime factorization of the numbers from 1
to 20
and combining them.
Problem 6
Rather straight forward solution to this problem. I am still surprised by how clean the code looks in haskell
compared to c++
. There is much less boilerplate code required to get a solution printed on screen.
Problem 7
Another really clean solution using infinite lists.
Problem 8 from Project Euler is looking like a much more involved problem however, I’m hopeful that I will be able to get it finished this week.