I am aware of how simply this could have been done could have been done, but I was trying to do this in a vacuum as much as possible.
I am aware of how simply this could have been done, but I was trying to do this in a vacuum as much as possible.
I am aware of how simply this could have been done, but I was trying to do this in a vacuum as much as possible.
In the pursuit of learning f#F#, I have been working through some Project Euler problems.
I am new to both prime factorization and F#,F#; however, I am really only looking for comments on F#, not how poorly my factorization algorithm works (I know it's bad). i.e. what style mistakes am I making, or how the code could be made more functional.
In the pursuit of learning f#, I have been working through some Project Euler problems.
I am new to both prime factorization and F#, however I am really only looking for comments on F# not how poorly my factorization algorithm works (I know it's bad). i.e. what style mistakes am I making, or how the code could be made more functional.
In the pursuit of learning F#, I have been working through some Project Euler problems.
I am new to both prime factorization and F#; however, I am really only looking for comments on F#, not how poorly my factorization algorithm works (I know it's bad) i.e. what style mistakes am I making, or how the code could be made more functional.
Update
After thinking more about my solution overnight, I had more thought about exactly what my solution was doing, and why the simpler methods are so much simpler.
During my research on factoring primes, I think I got too caught up in the sieve of Eratosthenes , and didn't focus on the actual problem.
What I should have been trying to do:
- Search for the smallest prime factor
- Once found save it to the list of prime factors
- Divide this factor out of the number to be factored
- Repeat from step 1 substituting the number to be factored with the quotient from step 3, and start the search from the prime factor found in step 2.
- Get the biggest prime from the list.
What I actually did:
- Search for all prime numbers from 2 to the square root of the number to be factored.
- During the search, check each prime to see if it divides evenly.
- Once complete divide each of these "small primes" to generate a list potential big primes.
- Divide each of the big primes by all of the small primes as a test for primality.
- Combined the lists, and get the biggest one.
Update
After thinking more about my solution overnight, I had more thought about exactly what my solution was doing, and why the simpler methods are so much simpler.
During my research on factoring primes, I think I got too caught up in the sieve of Eratosthenes , and didn't focus on the actual problem.
What I should have been trying to do:
- Search for the smallest prime factor
- Once found save it to the list of prime factors
- Divide this factor out of the number to be factored
- Repeat from step 1 substituting the number to be factored with the quotient from step 3, and start the search from the prime factor found in step 2.
- Get the biggest prime from the list.
What I actually did:
- Search for all prime numbers from 2 to the square root of the number to be factored.
- During the search, check each prime to see if it divides evenly.
- Once complete divide each of these "small primes" to generate a list potential big primes.
- Divide each of the big primes by all of the small primes as a test for primality.
- Combined the lists, and get the biggest one.