summaryrefslogtreecommitdiffstats
path: root/Demo/scripts/fact.py
diff options
context:
space:
mode:
Diffstat (limited to 'Demo/scripts/fact.py')
-rwxr-xr-xDemo/scripts/fact.py8
1 files changed, 3 insertions, 5 deletions
diff --git a/Demo/scripts/fact.py b/Demo/scripts/fact.py
index 19d28eb..c76474c 100755
--- a/Demo/scripts/fact.py
+++ b/Demo/scripts/fact.py
@@ -8,23 +8,21 @@
import sys
from math import sqrt
-error = 'fact.error' # exception
-
def fact(n):
- if n < 1: raise error # fact() argument should be >= 1
+ if n < 1: raise ValueError # fact() argument should be >= 1
if n == 1: return [] # special case
res = []
# Treat even factors special, so we can use i = i+2 later
while n%2 == 0:
res.append(2)
- n = n/2
+ n = n//2
# Try odd numbers up to sqrt(n)
limit = sqrt(float(n+1))
i = 3
while i <= limit:
if n%i == 0:
res.append(i)
- n = n/i
+ n = n//i
limit = sqrt(n+1)
else:
i = i+2