0
$\begingroup$

This question already has an answer here:

How do I write a decimal expansion of a rational number $a/b$ with only periodic part, e.g., given $1/7=0.14285714285714285714 \ldots$, I want just $0.142857$, the periodic part of $1/7$, to be displayed. I think I was able to do it sometime ago (with RealDigit or something similar), but now I forget what I did.

$\endgroup$

marked as duplicate by Coolwater, rhermans, m_goldberg, garej, yarchik Jul 22 at 18:57

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

2
$\begingroup$

Straight from the docs:

For integers and rational numbers with terminating digit expansions, RealDigits[x] returns an ordinary list of digits. For rational numbers with non‐terminating digit expansions, it yields a list of the form {a1,a2,…,{b1,b2,…}} representing the digit sequence consisting of the ai followed by infinite cyclic repetitions of the bi

Print@RealDigits[1/7]
(* {{{1, 4, 2, 8, 5, 7}}, 0} *)

Try it online!

If you instead want to display real numbers in periodic form (with an overbar), use this answer.

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.