Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
#! /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