Permalink
Browse files

Added a handful of scripts

  • Loading branch information...
1 parent 4b333b6 commit d27ede1b926c3ba91e042725b3ecf8f584c028be @hurdlecrew committed Jan 3, 2012
Showing with 1,943 additions and 0 deletions.
  1. +80 −0 bin/circular_primes.pl
  2. +8 −0 bin/factor.pl
  3. +8 −0 bin/hexagonal.pl
  4. +1,810 −0 bin/triangle_words.pl
  5. +37 −0 lib/Palindrome.pm
View
@@ -0,0 +1,80 @@
+#!/usr/local/bin/perl
+
+use strict;
+use warnings;
+
+my $limit = shift;
+my %hash;
+
+ITERATOR:
+foreach my $n (1..$limit) {
+ next ITERATOR if $n =~ /0|2|4|5|6|8/;
+ next ITERATOR if digitsum($n) % 3 == 0;
+ $hash{$n}++ if is_prime($n) and popoff($n);
+}
+
+
+$hash{2}++;
+$hash{3}++;
+$hash{5}++;
+
+local $, = "\n";
+print keys %hash;
+
+
+
+
+
+
+
+sub popoff
+{
+ my $n = shift;
+ my @n = split //, $n;
+ my $popnext = join('', $n[-1], @n[0..$#n-1]);
+ return unless is_prime($popnext);
+ my @popnext = split //, $popnext;
+ $popnext = join('', $popnext[-1], @popnext[0..$#popnext-1]);
+ return unless is_prime($popnext);
+ @popnext = split //, $popnext;
+ $popnext = join('', $popnext[-1], @popnext[0..$#popnext-1]);
+ return unless is_prime($popnext);
+ @popnext = split //, $popnext;
+ $popnext = join('', $popnext[-1], @popnext[0..$#popnext-1]);
+ return unless is_prime($popnext);
+ @popnext = split //, $popnext;
+ $popnext = join('', $popnext[-1], @popnext[0..$#popnext-1]);
+ return unless is_prime($popnext);
+ @popnext = split //, $popnext;
+ $popnext = join('', $popnext[-1], @popnext[0..$#popnext-1]);
+ return unless is_prime($popnext);
+ @popnext = split //, $popnext;
+ $popnext = join('', $popnext[-1], @popnext[0..$#popnext-1]);
+ return unless is_prime($popnext);
+ @popnext = split //, $popnext;
+ $popnext = join('', $popnext[-1], @popnext[0..$#popnext-1]);
+ return unless is_prime($popnext);
+ return 1;
+}
+
+sub digitsum
+{
+ my $i = shift;
+ my @i = split //, $i;
+ my $sum = 0;
+ foreach my $j (@i) {
+ $sum += $j;
+ }
+ return $sum;
+}
+
+sub is_prime
+{
+ my $n = shift;
+ foreach my $i (2,3..int(sqrt($n)+1)) {
+ if ($n % $i == 0) {
+ return 0;
+ }
+ }
+ return 1;
+}
View
@@ -0,0 +1,8 @@
+#!/usr/local/bin/perl
+use strict;
+use warnings;
+use Factor qw(divisors);
+
+local $, = ' ';
+print divisors(shift);
+print "\n";
View
@@ -0,0 +1,8 @@
+#!/usr/local/bin/perl
+use strict;
+use warnings;
+use lib '.';
+use Hexagonal qw(hexagonal);
+
+my $arg = shift;
+print "$arg is " . (Hexagonal::hexagonal($arg) ? '' : 'NOT ') . "hexagonal\n";
Oops, something went wrong.

0 comments on commit d27ede1

Please sign in to comment.