Created
April 8, 2015 16:49
-
-
Save trys/f6fa5ca1ec688813835c to your computer and use it in GitHub Desktop.
Problem Twelve
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 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