Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
I mean you need up to
sqrt(n)+1
non/2+1
No, try the previous algorithm. It will time out.
The logic behind this is to greatly reduce numbers looped, sometimes up to one fourth, especially on large numbers. When I get a divisor I get its complement. When I reach a number that is already in the list, I know that I have already reached the second side of divisors, thus I have got everything. I can get out of the loop after that. For example, let's see how 12 is processed:
Actually I can optimize it further by using
fromkeys
You are looping over much more integers than needed
Please check the fork; the fork can view over less than one half.
But your algorithm is still great!
Both algorithms are linear on the input; but yes, this one is faster
I think that no number has a divisor larger than it's half other than itself too .
This program works faster because it doesn't go through the entire range, you only need to view half of it