Skip to content

Instantly share code, notes, and snippets.

@gfldex
Created January 12, 2022 20:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gfldex/7b2f312317dc7a598c2627367a05f3fd to your computer and use it in GitHub Desktop.
Save gfldex/7b2f312317dc7a598c2627367a05f3fd to your computer and use it in GitHub Desktop.
#! /usr/bin/env -S raku --profile=pentathing-profile.html
use v6.*;
sub is-pentagon($c is raw) { (1+sqrt(1+24*$c))%%6 }
sub P($n is raw) { $n*(3*$n-1) div 2 }
my atomicint $bail = 0;
(^∞).hyper(:batch(64)).map( -> \b {
last if $bail;
for (1..^b) -> \s {
my \bp = P(b);
my \sp = P(s);
if is-pentagon(bp + sp) && is-pentagon(bp - sp) {
say [b, s];
$bail⚛++;
say now - BEGIN now;
last;
}
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment