Message225576
>>> import fractions
>>> fractions.gcd(16, float('inf'))
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
fractions.gcd(16, float('inf'))
File "C:\Python34-32bit\lib\fractions.py", line 24, in gcd
a, b = b, a%b
KeyboardInterrupt
>>> fractions.gcd(16, float('nan'))
Traceback (most recent call last):
File "<pyshell#2>", line 1, in <module>
fractions.gcd(16, float('nan'))
File "C:\Python34-32bit\lib\fractions.py", line 24, in gcd
a, b = b, a%b
KeyboardInterrupt
>>>
With the iterative algorithm that is used
a, b = b, a%b
b converges to float('nan'). It will never become 0 to break out of the loop. It might be nice to error when the iteration has converged b to a value other than 0. |
|
Date |
User |
Action |
Args |
2014-08-20 17:31:43 | snoeberger | set | recipients:
+ snoeberger |
2014-08-20 17:31:43 | snoeberger | set | messageid: <1408555903.78.0.619851425654.issue22238@psf.upfronthosting.co.za> |
2014-08-20 17:31:43 | snoeberger | link | issue22238 messages |
2014-08-20 17:31:43 | snoeberger | create | |
|