diff --git a/45 b/45 new file mode 100755 index 0000000..e08ef71 Binary files /dev/null and b/45 differ diff --git a/45.c b/45.c new file mode 100644 index 0000000..37bafe8 --- /dev/null +++ b/45.c @@ -0,0 +1,22 @@ +#include +#include +#include +#include + +bool isPentagonal (long long n) { + long long radicand = 24*n + 1; + long long sqrtr = sqrt (radicand); + return sqrtr * sqrtr == radicand && (sqrtr + 1) % 6 == 0; +} + +int main () { + long long n = 144LL; + while (true) { + long long hex = n * (2*n - 1); + if (isPentagonal (hex)) { + printf ("%lli\n", hex); + break; + } + n++; + } +}