Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def quotientKthDigitAfterDecimalPoint(a, b, k)
- a = a * 1.0
- b = b * 1.0
- number = (a / b)
- string = number.to_s
- string_length = string.length
- result = 0
- x = 0
- y = 0
- if a % b == 0 then
- return 0
- end
- while (x < string_length)
- if string[x] == "." then
- while (y <= k)
- result = string[x]
- x = x + 1
- y = y + 1
- if y == 16 then
- break
- end
- end
- break
- end
- x = x + 1
- end
- return result.to_i
- end
Advertisement
Add Comment
Please, Sign In to add comment