File: matho-mult

package info (click to toggle)
mathomatic 16.0.5-5.1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 2,192 kB
  • sloc: ansic: 22,029; makefile: 340; sh: 319; python: 96; awk: 39
file content (27 lines) | stat: -rwxr-xr-x 693 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
#!/usr/bin/python3

# Python program to multiply many large integers separated by spaces or newlines.
# The integers to multiply may be entered on the command-line or into standard input.

# Used by "primorial" with "matho-primes" to calculate large primorials.
# A primorial is the product of all primes up to a given number.

import string
import sys

prod = 1 # initialize product and make it an integer
args = sys.argv[1:]
if (args == []):
	# read stdin if no command line args
	while True:
		try:
			input_line = input()
		except:
			break;
		for s in input_line.split():
			prod *= int(s)
else:
	# multiply together the command-line args
	for arg in args:
		prod *= int(arg)
print(prod)