[t][TT #1119] Convert t/op/bitwise.t to PIR
[parrot.git] / examples / benchmarks / primes2.py
blob3f14a75e7cfc3f001831be97494057d9d23849dd
1 """
2 Copyright (C) 2001-2003, Parrot Foundation.
3 $Id$
5 =head1 NAME
7 examples/benchmarks/primes.py - Calculate prime numbers < 5000
9 =head1 SYNOPSIS
11 % time python examples/benchmarks/primes.py
13 =head1 DESCRIPTION
15 Calculates all the prime numbers up to 50000 and prints out the number
16 of primes and the last one found.
18 =cut
20 """
22 # import os,sys
23 def isprime1(input):
24 if input < 1:
25 return 0
27 n = input-1
29 while n > 1:
30 if input%n == 0:
31 return 0
32 n = n - 1
34 return 1
36 def main():
37 i = 0
38 l = 0
39 i6 = 0
40 i7 = 0
41 max = 500
43 while 1:
45 if isprime1(i):
46 i6 = i6 + 1
47 i7 = i
48 i = i + 1
49 if i == max:
50 break
52 print "N primes calculated to ",max, i6
53 print "last is:", i7
55 if __name__ == "__main__":
56 main()
58 """
60 =head1 SEE ALSO
62 F<examples/benchmarks/primes.c>,
63 F<examples/benchmarks/primes.pasm>,
64 F<examples/benchmarks/primes.pl>,
65 F<examples/benchmarks/primes2_p.pasm>,
66 F<examples/benchmarks/primes2.c>,
67 F<examples/benchmarks/primes2.pir>,
68 F<examples/benchmarks/primes2.py>.
70 =cut
72 """