DEV Community

Discussion on: Math and Ruby: Project Euler Problem 1

Collapse
 
amin_foroutan profile image
Amin Foroutan • Edited

Actually I think there is a better method,by multiplying numbers from 1 to 333 to 3 we can find all multiples of 3 and then multiplying from 1 to 200 without considering multiples of 3( we've already counted them) to 5. this way we can change the iteration count from n (being the max number indicated) to n mod m ( m being the number we check, i.e 3 or 5) but overall both solutions have time complexity of O(n).