Zulip Chat Archive
Stream: new members
Topic: How to prove that the decimal part of a rational number is c
tooball (Jan 06 2025 at 13:00):
How to prove that the decimal part of a rational number is cyclic?
If I want to express a decimal place of a rational number, such as the 100th place of 6/7, without using direct calculation, how should I formalize the problem.
Zhang Qinchuan (Jan 06 2025 at 15:37):
It seems that there is no such thing in Mathlib, just define one yourself.
import Mathlib
def decimal_after_pt (x : ℚ) (n : ℕ) : ℕ :=
Nat.floor (x * 10 ^ (n + 1)) % 10
def x : ℚ := 6 / 7
-- [8, 5, 7, 1, 4, 2, 8, 5, 7, 1, 4, 2]
#eval (List.range (6 * 2)).map (decimal_after_pt x ·)
Last updated: May 02 2025 at 03:31 UTC