New == syntax

This commit is contained in:
Guido van Rossum 1992-01-01 19:35:13 +00:00
parent 4d8e859e8f
commit bdfcfccbe5
73 changed files with 419 additions and 391 deletions

View file

@ -12,17 +12,17 @@ error = 'fact.error' # exception
def fact(n):
if n < 1: raise error # fact() argument should be >= 1
if n = 1: return [] # special case
if n == 1: return [] # special case
res = []
# Treat even factors special, so we can use i = i+2 later
while n%2 = 0:
while n%2 == 0:
res.append(2)
n = n/2
# Try odd numbers up to sqrt(n)
limit = sqrt(n+1)
i = 3
while i <= limit:
if n%i = 0:
if n%i == 0:
res.append(i)
n = n/i
limit = sqrt(n+1)