1. tomo cocoa
  2. SICP with Python

Commits

tomo cocoa  committed 93fe7a0

integer division

  • Participants
  • Parent commits 0b23a86
  • Branches default

Comments (0)

Files changed (1)

File chap1.py

View file
     if n == 0:
         return 1
     elif even(n):
-        return square(fast_expt(b, n / 2))
+        return square(fast_expt(b, n // 2))
     else:
         return b * fast_expt(b, n - 1)
 
     if exponent == 0:
         return product
     elif even(exponent):
-        return expt_iter(square(b), exponent / 2, product)
+        return expt_iter(square(b), exponent // 2, product)
     else:
-        return expt_iter(square(b), (exponent - 1) / 2, b * product)
+        return expt_iter(square(b), (exponent - 1) // 2, b * product)
 
 
 def test_expt2():