# Hackerrank – Project Euler+ #012 – Highly divisible triangular number

## Hackerrank – Problem description

The problem description – Hackerrank.

## Solution

I check all numbers from 1 to N. I need to do a prime factorization of each number. In the end there is a following state:

. To calculate the prime numbers I use for example Sieve of Eratosthenes. I calculate the exponents and product of calculated exponent values:

.
If there exists a number with

value greater than given amount, it is the result.

Prime factorization is used for calculating all divisors. For example

is divisible by

and

, so factorized

is:

.

Let’s take for example the number

:

All divisors of

are combinations of numbers when changing range of calculated exponent.There is

prime number to be combined from

to

exponent and

from

to

. These are the combinations:

There are

divisors for

– one exponent is

and second

. We can use

as an exponent, too. That’s why we have to multiply incremented exponent value.

I created solution in:

All solutions are also available on my GitHub profile.