Skip to content

Instantly share code, notes, and snippets.

@gennad
Created May 27, 2011 08:26
Show Gist options
  • Save gennad/994851 to your computer and use it in GitHub Desktop.
Save gennad/994851 to your computer and use it in GitHub Desktop.
Деление
# -*- coding: utf-8 -*-
# Целочисленне деление без оператора "деление"
def div(a,b):
if a < b:
return 0
elif a == b:
return 1
counter = 1
process = True
while (process):
if b * (counter + 1) <= a:
counter += 1
else:
process = False
return counter
print div(50, 5) # 10
print div(10, 5) # 2
print div(10, 10) # 1
print div(10, 9) # 1
print div(8, 9) # 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment