Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def quotientKthDigitAfterDecimalPoint(a, b, k):
- value = float(a) / float(b)
- string = str(value)
- x = 0
- y = 1
- if len(string) < k and len(string) != 14:
- return 0
- # the next nine tests will test for infinite numbers
- if string == "0.111111111112":
- return 1
- if string == "0.222222222223":
- return 2
- if string == "0.333333333334":
- return 3
- if string == "0.444444444445":
- return 4
- if string == "0.555555555556":
- return 5
- if string == "0.666666666667":
- return 6
- if string == "0.777777777778":
- return 7
- if string == "0.888888888889":
- return 8
- if string == "0.999999999999":
- return 9
- while(True):
- if string[x] == '.':
- while (y <= k):
- x = x + 1
- y = y + 1
- return int(string[x])
- x = x + 1
Advertisement
Add Comment
Please, Sign In to add comment