求循環小數的開始位置(小數點之後的位數)和循環長度(Python3)

首先要清楚,循環小數中,一個循環內相同的數是不會出現兩次的,循環數的範圍又在0~9。  Python3代碼如下: def function(a,b): index = 0 d = collections.defaultdict(int) while True: remainder = a%b if not remainder:
相關文章
相關標籤/搜索