Created
September 22, 2015 19:44
-
-
Save trys/8648b49f164f9d00875c to your computer and use it in GitHub Desktop.
Problem Fourteen
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var termCount = 1, | |
termTotal = 1, | |
termIndex = 0; | |
current = 13, | |
discountable = {}; | |
for ( var i = 1; i < 1000000; i++ ) { | |
current = i; | |
if ( ! ( current in discountable ) ) { | |
while ( current != 1 ) { | |
if ( current % 2 === 0 ) { | |
current = current / 2; | |
} else { | |
current = current * 3 + 1; | |
} | |
discountable.current = null; | |
termCount++; | |
} | |
if ( termCount > termTotal ) { | |
termIndex = i; | |
} | |
termCount = 0; | |
} | |
} | |
document.write( termIndex ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment