#!/usr/bin/perl -w use strict; system 'clear'; print "I will calculate the primes from 1 to the number you enter. What is the maximum number to check?\n"; my $max = ; $max > 0 or die "Negatives or 0 not allowed!\n"; my $getal = $max + 1; for (; $getal--; $getal >= 0) { my $deeltal = 2; # A/B would give B in this case my $teller = 0; # A/B would give A in this case while ($getal % $deeltal != 0 and $deeltal + 2 <= $getal) { $teller++; $deeltal++; } if ($teller + 3 == $getal) { push @priemlijst, $getal; } } system 'clear'; push @priemlijst, 2; # Don't forget number 2! @priemlijst = reverse @priemlijst; print "The primes from 1 to $max are: @priemlijst\n";