Proposed Solution for Euler Challenge - Highly Divisible Triangular Number

I noticed there wasn’t a solution for this one.

What is your hint or solution suggestion?
It basically generates new triangular numbers and counts its divisors up to root n. For each one, it adds 2 since there is also a factor above root n. When we reach the count, just return it. There might be a more efficient way, but this one is reasonable fast with large numbers.

/* Solution Function */
let divisibleTriangleNumber = (n) => {

    /* For every divisior below root n, there is also one above root n */
    let currentTriangular = 0
    let count = 0


        /* Generate a new triangular number */
        count = count + 1
        currentTriangular = currentTriangular + count

        /* Look for divisors between 2 and square root n, if we find one
            there is also one above root n, so add 2 to the divisor count */

        let divisorCount = 0
        let i
        for(i = 1; i < Math.sqrt(currentTriangular); i ++){
            if(currentTriangular % i === 0){
                divisorCount = divisorCount + 2;
            divisorCount = divisorCount + 1

        console.log('Generated Triangular ' + currentTriangular + ' with ' + divisorCount + ' divisors.')

        /* If number of divisors exceed n, then return the triangular number */
        if(divisorCount > n){
            return currentTriangular


Challenge: Problem 12: Highly divisible triangular number

Link to the challenge:

Hello there.

Thank you, for your contribution. For future contributions, please wrap your solution within :

code goes here...

Also, provide all of the necessary code to pass the challenge.

Also, when you enter a code block into a forum post, please precede it with a separate line of three backticks and follow it with a separate line of three backticks to make it easier to read.

You can also use the “preformatted text” tool in the editor ( </> ) to add backticks around text.

See this post to find the backtick on your keyboard.
Note: Backticks (`) are not single quotes (’).