Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

If you are under Python 2.x use xrange instead of range for loops.[XRange Doc][Xrange vs range][Xrange vs range]

A good optimization for big cases of this problem is to start mapping them to avoid recalculating every step. So only if it hits an unknown number it will either multiply or divide and continue. Have a look at the Collatz conjecture and its properties: http://en.wikipedia.org/wiki/Collatz_conjecture

If you are under Python 2.x use xrange instead of range for loops.[XRange Doc][Xrange vs range]

A good optimization for big cases of this problem is to start mapping them to avoid recalculating every step. So only if it hits an unknown number it will either multiply or divide and continue. Have a look at the Collatz conjecture and its properties: http://en.wikipedia.org/wiki/Collatz_conjecture

If you are under Python 2.x use xrange instead of range for loops.[XRange Doc][Xrange vs range]

A good optimization for big cases of this problem is to start mapping them to avoid recalculating every step. So only if it hits an unknown number it will either multiply or divide and continue. Have a look at the Collatz conjecture and its properties: http://en.wikipedia.org/wiki/Collatz_conjecture

Post Migrated Here from stackoverflow.com (revisions)
Source Link

If you are under Python 2.x use xrange instead of range for loops.[XRange Doc][Xrange vs range]

A good optimization for big cases of this problem is to start mapping them to avoid recalculating every step. So only if it hits an unknown number it will either multiply or divide and continue. Have a look at the Collatz conjecture and its properties: http://en.wikipedia.org/wiki/Collatz_conjecture