Skip to content

Instantly share code, notes, and snippets.

@trys
Created September 22, 2015 19:44
Show Gist options
  • Save trys/8648b49f164f9d00875c to your computer and use it in GitHub Desktop.
Save trys/8648b49f164f9d00875c to your computer and use it in GitHub Desktop.
Problem Fourteen
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