[libmath-prime-util-perl] 43/55: Add Catalan sequence using binomial
Partha P. Mukherjee
ppm-guest at moszumanska.debian.org
Thu May 21 18:53:42 UTC 2015
This is an automated email from the git hooks/post-receive script.
ppm-guest pushed a commit to annotated tag v0.41
in repository libmath-prime-util-perl.
commit d761934cdb06990a1b564cb8f8a236138b94ada7
Author: Dana Jacobsen <dana at acm.org>
Date: Tue May 13 22:10:33 2014 -0700
Add Catalan sequence using binomial
---
examples/numseqs.pl | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/examples/numseqs.pl b/examples/numseqs.pl
index 23ace8f..314e0cd 100755
--- a/examples/numseqs.pl
+++ b/examples/numseqs.pl
@@ -2,7 +2,6 @@
use warnings;
use strict;
use Math::Prime::Util qw/:all/;
-use List::Util qw/sum max/;
use Math::BigInt try=>"GMP";
# This shows examples of many sequences from:
@@ -75,6 +74,10 @@ if ($type eq 'Abundant') {
push @n, $i++;
}
print join " ", @n;
+} elsif ($type eq 'Catalan') {
+ # Done via pred. Much faster than MNS pred, but much slower than iterator
+ @n = map { binomial( $_<<1, $_) / ($_+1) } 0 .. $count-1;
+ print join " ", @n;
} elsif ($type eq 'Cubes') {
# Done via pred to show use
my $i = 0;
@@ -245,7 +248,7 @@ if ($type eq 'Abundant') {
} elsif ($type eq 'Totient') {
print join " ", euler_phi(1,$count);
} elsif ($type eq 'TotientCumulative') {
- # pred: sum(euler_phi(0,$_[0]));
+ # pred: vecsum(euler_phi(0,$_[0]));
my $c = 0;
print join " ", map { $c += euler_phi($_) } 0..$count-1;
} elsif ($type eq 'TotientPerfect') {
@@ -278,7 +281,6 @@ if ($type eq 'Abundant') {
# Base::IteratePred
# BaumSweet
# Beastly
-# Catalan
# CollatzSteps
# ConcatNumbers
# CullenNumbers
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-perl/packages/libmath-prime-util-perl.git
More information about the Pkg-perl-cvs-commits
mailing list