corrade-nucleus-nucleons – Blame information for rev 20
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
20 | office | 1 | #!/usr/bin/perl |
2 | =begin |
||
3 | perl example code for Ace |
||
4 | =cut |
||
5 | |||
6 | use strict; |
||
7 | use warnings; |
||
8 | my $num_primes = 0; |
||
9 | my @primes; |
||
10 | |||
11 | # Put 2 as the first prime so we won't have an empty array |
||
12 | $primes[$num_primes] = 2; |
||
13 | $num_primes++; |
||
14 | |||
15 | MAIN_LOOP: |
||
16 | for my $number_to_check (3 .. 200) |
||
17 | { |
||
18 | for my $p (0 .. ($num_primes-1)) |
||
19 | { |
||
20 | if ($number_to_check % $primes[$p] == 0) |
||
21 | { |
||
22 | next MAIN_LOOP; |
||
23 | } |
||
24 | } |
||
25 | |||
26 | # If we reached this point it means $number_to_check is not |
||
27 | # divisable by any prime number that came before it. |
||
28 | $primes[$num_primes] = $number_to_check; |
||
29 | $num_primes++; |
||
30 | } |
||
31 | |||
32 | for my $p (0 .. ($num_primes-1)) |
||
33 | { |
||
34 | print $primes[$p], ", "; |
||
35 | } |
||
36 | print "\n"; |
||
37 |