now having a big single function
authorHeiko Schlittermann (JUMPER) <hs@schlittermann.de>
Sat, 29 Oct 2011 22:18:16 +0200
changeset 7 6a025d656935
parent 6 ad2ed8ef3e21
child 8 27520a5fe8a4
now having a big single function
prime
--- a/prime	Sat Oct 29 22:11:42 2011 +0200
+++ b/prime	Sat Oct 29 22:18:16 2011 +0200
@@ -17,25 +17,23 @@
 die "$ME: Sorry, number >= 2 expected!\n"
   if $number < 2;
 
-#1. find all divisors of $number
-my @divisors = findDivisors($number);
-
-#print "Die Teiler von $number sind: @divisors\n";
-
-#2. delete all non primes
-my @primes = findPrimes(@divisors);
-
-#print "Die Primzahlteile von $number sind: @primes\n";
-
-# not sure about the name of the function! // .hs
-@primes = factorize($number, @primes);
-
-print join("*", @primes), "\n";
+print join("*", getPrimes($number)), "\n";
 
 exit;
 
 #### SUBROUTINES #####
 
+# hey, this is the shortcut for calling all
+# thress steps in one single row…
+# @a = findDivisors($number);
+# @b = findPrimes(@a);
+# @c = factorize($number, @b);
+# would do the same
+sub getPrimes {
+    my $number = shift;
+    return factorize($number, findPrimes(findDivisors($number)));
+}
+
 sub findDivisors {
     my $i = 2;
     my $m = $_[0];