Introduction
A pentagonal number (A000326) is generated by the formula Pn= 0.5×(3n2-n). Or you can just count the amount of dots used:
You can use the formula, or the gif above to find the first few pentagonal numbers:
1, 5, 12, 22, 35, 51, 70, 92, 117, 145, 176, 210, 247, 287, 330, 376, 425, 477, etc...
Next, we need to compute the sum of x consecutive numbers.
For example, if x = 4, we need to look at Pn + Pn+1 + Pn+2 + Pn+3 (which consists of 4 terms). If the sum of the pentagonal numbers also is a pentagonal number, we will call this a pentagonal pentagon number.
For x = 4, the smallest pentagonal pentagon number is 330
, which is made of 4 consecutive pentagonal numbers: 51, 70, 92, 117
. So, when the input is 4
, your program of function should output 330
.
Task
- When given an integer greater than 1, output the smallest pentagonal pentagon number.
- You may provide a function or a program.
- Note: There are no solutions for e.g. x = 3. This means that if a number cannot be made from the first 10000 pentagonal numbers, you must stop computing and output whatever fits best for you.
- This is code-golf, so the submission with the least amount of bytes wins!
Test cases:
Input: 2
Output: 1926 (which comes from 925, 1001)
Input: 3
Output: ?
Input: 4
Output: 330 (which comes from 51, 70, 92, 117)
Input: 5
Output: 44290 (which comes from 8400, 8626, 8855, 9087, 9322)
Input: 6
Output: 651 (which comes from 51, 70, 92, 117, 145, 176)
Input: 7
Output: 287 (which comes from 5, 12, 22, 35, 51, 70, 92)
Input: 8
Output: ?
Input: 9
Output: 12105 (which comes from 1001, 1080, 1162, 1247, 1335, 1426, 1520, 1617, 1717)
Input: 10
Output: ?
Also bigger numbers can be given:
Input: 37
Output: 32782
Input: 55
Output: 71349465
Input: 71
Output: 24565290
10001-x
\$\endgroup\$x = 3
, which has no solutions? \$\endgroup\$9919
-->496458299155
\$\endgroup\$