Debian Codegraph @

primes/matho-mult

raw ◀ ▶
1 Debian patch touch this file
•1 #!/usr/bin/python3
2
3 # Python program to multiply many large integers separated by spaces or newlines.
4 # The integers to multiply may be entered on the command-line or into standard input.
5
6 # Used by "primorial" with "matho-primes" to calculate large primorials.
7 # A primorial is the product of all primes up to a given number.
8
9 import string
10 import sys
11
12 prod = 1 # initialize product and make it an integer
13 args = sys.argv[1:]
14 if (args == []):
15 # read stdin if no command line args
16 while True:
17 try:
•18 input_line = input()
19 except:
20 break;
•21 for s in input_line.split():
22 prod *= int(s)
23 else:
24 # multiply together the command-line args
25 for arg in args:
26 prod *= int(arg)
•27 print(prod)