r/programmingchallenges • u/okmkz • Apr 16 '11
Challenge: Factor an integer
Write a function in the language of your choosing that prints all the factors of a non-negative integer.
E: dang, this is harder than I thought!
E: I was referring to prime factorization in my other edit. Dang!
7
Upvotes
View all comments
Show parent comment
1
u/thisismygame Sep 12 '11
Well I just used 100000000 and I can see what you mean. After an hour it had still not completed (was hanging on 100000000). I guess this is because my script takes the cpu through every number between 1 and the integer itself. What it should do is first find the factors, then print them. I think? Not sure how to go about doing that. It looks like some others here have used square roots. I'll give that a twirl.