2

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.

yarchik
  • 18,202
  • 2
  • 28
  • 66

2 Answers2

5

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} *)

Length[%] (* 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 ...

Domen
  • 23,608
  • 1
  • 27
  • 45
  • And the period is? Notice, however, that `[[1, -1]]´syntax might be hard to understand for children. – yarchik May 04 '23 at 19:14
  • @yarchik: Dimensions[RealDigits[r][[1, -1]]][[1]] results in 18. – user64494 May 04 '23 at 19:55
  • 1
    @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. – Michael E2 May 04 '23 at 22:31
  • @MichaelE2 Yes, this is probably the way to go. – yarchik May 05 '23 at 05:49
  • @yarchik, sorry, I somehow forgot about the period. – Domen May 05 '23 at 07:03
2

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

ubpdqn
  • 60,617
  • 3
  • 59
  • 148