use a sage function for polygonal numbers
This commit is contained in:
parent
4f40147212
commit
a881f7518d
|
@ -7,7 +7,7 @@
|
|||
"source": [
|
||||
"# [Highly Divisible Triangular Number](https://projecteuler.net/problem=12)\n",
|
||||
"\n",
|
||||
"Yet another problem with a straightforward solution thanks to SageMath's preinstalled functions. We'll also once again apply the closed formula for triangle numbers (see [problem 1](https://projecteuler.net/problem=1))."
|
||||
"Yet another problem with a straightforward solution thanks to SageMath's preinstalled functions. Triangular numbers fall into the broader category of [polygonal numbers](https://en.wikipedia.org/wiki/Polygonal_number)."
|
||||
]
|
||||
},
|
||||
{
|
||||
|
@ -26,7 +26,7 @@
|
|||
],
|
||||
"source": [
|
||||
"for n in PositiveIntegers():\n",
|
||||
" t = n * (n+1) / 2\n",
|
||||
" t = polygonal_number(3, n)\n",
|
||||
" if number_of_divisors(t) > 500:\n",
|
||||
" print(t)\n",
|
||||
" break"
|
||||
|
|
Loading…
Reference in New Issue