Skip to content

Instantly share code, notes, and snippets.

@trys
Created April 8, 2015 16:49
Show Gist options
  • Save trys/f6fa5ca1ec688813835c to your computer and use it in GitHub Desktop.
Save trys/f6fa5ca1ec688813835c to your computer and use it in GitHub Desktop.
Problem Twelve
var count = 1,
divisors = 0,
currentTriangle = 0;
while ( divisors <= 500 ) {
currentTriangle += count;
divisors = 0;
for ( var k = 1; k < currentTriangle / 2; k++ ) {
if ( currentTriangle % k !== 0 )
continue;
divisors += 2;
if ( currentTriangle / k <= k )
break;
}
count++;
}
document.write( currentTriangle );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment