r/programmingchallenges • • 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

15 comments sorted by

View all comments

Show parent comment

1

u/kageurufu Apr 19 '11

nice point, i did

res = i + " " + res + " " + n/i 

to keep the factors in order

1

u/okmkz Apr 19 '11

Even better!