I came across of a 6-grader school problem to perform the following division 357.56/19. Pupils in the school understand that both numbers are numerically exact.

I would like to introduce Mathematica to children. How can I explain them how to solve this problem in MA? How can one find the period of this number?

Please, be pedagogical in you answers. I came up with

N[35756/1900, 100]

for the first question. But I still do not know a simple answer for the second question.

  • 1
    $\begingroup$ They expect sixth graders to cough up a decimal where the repeating segment has length 18? They must seriously dislike sixth graders. $\endgroup$ May 4, 2023 at 19:24
  • 1
    $\begingroup$ @DanielLichtblau Yes, this is a real world case in Germany :) $\endgroup$
    – yarchik
    May 4, 2023 at 19:26
  • 3
    $\begingroup$ And what do they do to seventh graders? Eat them? $\endgroup$ May 4, 2023 at 19:28
  • 4
    $\begingroup$ No, that's what they do to ate graders $\endgroup$
    – user1066
    May 4, 2023 at 19:49
  • 3
    $\begingroup$ Is an answer based on MultiplicativeOrder out of bounds? Assuming the denominator is relatively prime to 10, the length is just MultiplicativeOrder[10, denominator] $\endgroup$
    – Carl Woll
    May 4, 2023 at 20:02

2 Answers 2


As written on MathWorld, you can use RealDigits.

r = 35756/1900;
RealDigits[r][[1, -1]]
(* {8,9,4,7,3,6,8,4,2,1,0,5,2,6,3,1,5,7} *)

(* 18 *)

Pedagocially, you should probably – as proposed by @MichaelE2 – present this in several steps. First defining the number, then observing the structure of RealDigits[r], then extracting parts of the results (also possible with First and Last), then counting the numbers ...

  • $\begingroup$ And the period is? Notice, however, that `[[1, -1]]´syntax might be hard to understand for children. $\endgroup$
    – yarchik
    May 4, 2023 at 19:14
  • $\begingroup$ @yarchik: Dimensions[RealDigits[r][[1, -1]]][[1]] results in 18. $\endgroup$
    – user64494
    May 4, 2023 at 19:55
  • 1
    $\begingroup$ @yarchik I think you would have to explain the output syntax of RealDigits[r]. While clear (in a technical sense), the notation is new and unfamiliar and has lots of braces that mean nothing to a sixth-grade newbie. The [[-1, 1]] seems unnecessary, strictly speaking. They could copy and paste the answer from the output, if they needed to put the answer somewhere. $\endgroup$
    – Michael E2
    May 4, 2023 at 22:31
  • $\begingroup$ @MichaelE2 Yes, this is probably the way to go. $\endgroup$
    – yarchik
    May 5, 2023 at 5:49
  • $\begingroup$ @yarchik, sorry, I somehow forgot about the period. $\endgroup$
    – Domen
    May 5, 2023 at 7:03

To illustrate NestWhileList

f[x_, y_] :=
 Module[{nst = 
    NestWhileList[QuotientRemainder[10 #, y][[2]] &, 
     QuotientRemainder[x, y][[2]], Unequal, All, Infinity]},
  #2 - #1 & @@ (Flatten@Position[nst, nst[[-1]]])]

f[35756, 1900] yields 18


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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