# Five Ugly Truth About 12122122 12122122 Of 12122122 12122122 In Fraction Form | 12122 122 Of 12122 12 In Fraction Form

Posted on

Problem — A assemblage atom has 1 in the numerator. For eg — 1/2,1/3,1/4,1/5 etc. In their decimal representation they are —

1/2 = 0.5 1/3 = 0.(3) 1/4 = 0.25 1/5 = 0.2 1/6 = 0.1(6) 1/7 = 0.(142857) 1/8 = 0.125 1/9 = 0.(1) 1/10 = 0.1

Where 0.1(6)means , 0.1666666… and has a 1-digit alternating cycle. It can be apparent that 1/7 has a 6-digit alternating cycle. Accustomed an accumulation N, acquisition the aboriginal amount of d<N, such that d has the longest alternating cycle.

For eg, if N=10, the achievement should be 7 (1/7 has the longest alternating cycle).

This is botheration 26 from Project Euler. Another aberration is at hackerrank (different ascribe size).

The Math- One way of analytic this botheration is application Brute Force (long analysis method). That ability be abundant to break the Project Euler problem. However, with bigger ascribe of the hackerrank problem, this access will not work. Here is a cleverer solution.

If we address bottomward the aboriginal few assemblage fractions in decimal form, we can analyze three altered types of fractions –

Case 1 : Absolute Fractions

The absolute fractions are not of absorption to us in this catechism as the breadth of repeating aeon in these will consistently be according to 0. However, we charge to analyze the integers whose reciprocals anatomy absolute fractions. If 1/n is a absolute decimal, there exists an accumulation k, such that- Reducing Fractions for Reducing Fractions 13: Simplest Form | Math .. | 1 2 of 1 3 in fraction form

For eg,10²(1/4) = 100*0.25 = 25 => Here, k = 2.10¹(1/5) = 10*0.2 = 2 => Here, k = 1.

This implies

This is alone accessible if

And k will be according to the greater of ‘a’ and ‘b’.For eg, 1/4 = 1/2² 10²/2² = 25Here, k = 2. Times In Fraction Form Templates Remarkable 11113111131113 111131113 11113/111131113 11113111131113/1113 111131113/113 11113111131113/111131113 .. | 1 2 of 1 3 in fraction form

Case 2: Absolutely Repeating decimal

If 1/n is a absolutely repeating decimal, there exists an accumulation k such that –

For eg,1/7 = 0.(142857) ……………………………………… (eqn 1)10⁶(1/7) = 142857.(142857) ……………………………….(eqn 2)Here, k = 6.This implies –

For eg,Subtracting (eqn 1) from (eqn 2), we have:10⁶(1/7)-(1/7) = 142857Here, 10⁶ mod 7 = 1

Case 3: Repeating afterwards a non-repeating part

Thinking on the aforementioned curve as Case 1 and Case 2, we charge to attending for a way to represent a decimal that repeats afterwards a non-repeating allotment as an integer. An archetype is 1/6 = .1(6).Here, non-repeating allotment is of breadth 1 and repeating allotment is additionally of breadth 1.

We can accumulate 1/n by a assertive power, d, of 10 such that the non-repeating decimal allotment is on the larboard ancillary of the decimal point.If 1/n is a decimal amount that repeats afterwards a non-repeating part, there exists an accumulation d such that-

For eg,1/6 = 0.1(6)=> 10¹*(1/6) = 1.(6) …………………………………………………(eqn 1)Here, d = 1

There additionally exists an accumulation k such that

For eg,=> 10^(1 1)*(1/6) = 10²(1/6) = 16.(6)……………………………..(eqn 2)Here, k = 1

This implies-

For eg,Subtracting (eqn1) from (eqn2), we have-10²(1/6) — 10(1/6) = 15=> 10(10–1)/6 = 15=> 5(10–1)/3 = 15 ( Cancelling out multiples of 2 and 5 from n)Now, we break the allotment (10–1)/3 independentlyFrom Case2, this implies that we break for => 10^k mod 3 = 1. Here, k=1. Dividing fractions: 113/113 ÷ 113/13 (video) | Khan Academy – 1 2 of 1 3 in fraction form | 1 2 of 1 3 in fraction form

Once all multiples of 2 and 5 are annulled out from n, it can be apparent as Case 2 from above. In added words, the non-repeating allotment of the decimal representation is contributed to by the 2’s and 5’s in n. Since we are absorbed in the repeating cycle, we can factorize n, aish all multiples of ( 2 and 5) and break it as for Case 2 above.

Overview of the Algorithm–

Five Ugly Truth About 12122122 12122122 Of 12122122 12122122 In Fraction Form | 12122 122 Of 12122 12 In Fraction Form – 1 2 of 1 3 in fraction form
| Allowed for you to my blog site, with this moment I’ll teach you with regards to 1 2 of 1 3 in fraction form
.