Skip to content

Instantly share code, notes, and snippets.

@jnthn
Created October 28, 2011 22:58
Show Gist options
  • Save jnthn/1323796 to your computer and use it in GitHub Desktop.
Save jnthn/1323796 to your computer and use it in GitHub Desktop.
pir::nqp_bigint_setup__v();
my $knowhow := pir::get_knowhow__P();
my $bi_type := $knowhow.HOW.new_type(:name('TestBigInt'), :repr('P6bigint'));
$bi_type.HOW.compose($bi_type);
sub fac_bi($n) {
my $i := $n;
my $r := nqp::box_i(1, $bi_type);
while $i > 1 {
$r := pir::nqp_bigint_mul__PPP($r, nqp::box_i($i, $bi_type));
$i := $i - 1;
}
$r
}
say(pir::nqp_bigint_to_str__SP(fac_bi(1000)));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment