| Author |
Euler problem #1 - Spoiler Alert!
|
J. Kevin Robbins
Ranch Hand
Joined: Dec 16, 2010
Posts: 394
|
|
I've finally signed up for the Euler project to improve my math and programming skills. I'm interested in feedback on my first solution. I'm not looking for the fastest solution or the least number of lines of code, but rather using sound coding practices that can be applied to any problem.
Now, how could I go about improving this code?
|
"There is no reason for any individual to have a computer in his home" ~ Ken Olson, Co-founder of DEC, 1977
|
 |
Matthew Brown
Bartender
Joined: Apr 06, 2010
Posts: 3860
|
|
|
One thing that springs to mind is that you're effectively using two variables, i and numberToTest, for one purpose (iterating across the required range). That's more error prone because you've got to keep them in sync. I'd suggest just using numberToTest and looping from 1 to limit.
|
 |
J. Kevin Robbins
Ranch Hand
Joined: Dec 16, 2010
Posts: 394
|
|
Thanks, excellent advice. This is why I like to ask for a different perspective on things. New code:
|
 |
 |
|
|
subject: Euler problem #1 - Spoiler Alert!
|
|
|