RosettaCodeData/Task/Fraction-reduction/00-TASK.txt

70 lines
3.5 KiB
Plaintext

''There is a fine line between numerator and denominator.''       ''─── anonymous''
A method to &nbsp; "reduce" &nbsp; some reducible fractions is to &nbsp; ''cross out'' &nbsp; <u>a</u> digit from the
numerator and the denominator. &nbsp; An example is:
<big>16</big> <big>1<b><strike>6</strike></b></big>
──── and then (simply) cross─out the sixes: ────
<big>64</big> <big><b><strike>6</strike></b>4</big>
resulting in:
<big>1</big>
───
<big>4</big>
Naturally, &nbsp; this "method" of reduction must reduce to the proper value &nbsp; (shown as a fraction).
This "method" is also known as &nbsp; ''anomalous cancellation'' &nbsp; and also &nbsp; ''accidental cancellation''.
(Of course, &nbsp; this "method" shouldn't be taught to impressionable or gullible minds.) &nbsp; &nbsp; &nbsp; <big><big><big> 😇 </big></big></big>
;Task:
Find and show some fractions that can be reduced by the above "method".
:* &nbsp; show 2-digit fractions found &nbsp; (like the example shown above)
:* &nbsp; show 3-digit fractions
:* &nbsp; show 4-digit fractions
:* &nbsp; show 5-digit fractions &nbsp; (and higher) &nbsp; &nbsp; &nbsp; ''(optional)''
:* &nbsp; show each (above) n-digit fractions separately from other different n-sized fractions, don't mix different "sizes" together
:* &nbsp; for each "size" fraction, &nbsp; only show a dozen examples &nbsp; (the 1<sup>st</sup> twelve found)
:* &nbsp; (it's recognized that not every programming solution will have the same generation algorithm)
:* &nbsp; for each "size" fraction:
:::* &nbsp; show a count of how many reducible fractions were found. &nbsp; The example (above) is size '''2'''
:::* &nbsp; show a count of which digits were crossed out &nbsp; (one line for each different digit)
:* &nbsp; for each "size" fraction, &nbsp; show a count of how many were found. &nbsp; The example (above) is size '''2'''
:* &nbsp; show each n-digit example &nbsp; (to be shown on one line):
:::* &nbsp; show each n-digit fraction
:::* &nbsp; show each reduced n-digit fraction
:::* &nbsp; show what digit was crossed out for the numerator and the denominator
;Task requirements/restrictions:
:* &nbsp; only proper fractions and their reductions &nbsp; (the result) &nbsp; are to be used &nbsp; (no vulgar fractions)
:* &nbsp; only positive fractions are to be used &nbsp; (no negative signs anywhere)
:* &nbsp; only base ten integers are to be used for the numerator and denominator
:* &nbsp; no zeros &nbsp; (decimal digit) &nbsp; can be used within the numerator or the denominator
:* &nbsp; the numerator and denominator should be composed of the same number of digits
:* &nbsp; no digit can be repeated in the numerator
:* &nbsp; no digit can be repeated in the denominator
:* &nbsp; (naturally) &nbsp; there should be a shared decimal digit in the numerator &nbsp; ''and'' &nbsp; the denominator
:* &nbsp; fractions can be shown as &nbsp; 16/64 &nbsp; (for example)
Show all output here, on this page.
;Somewhat related task:
:* &nbsp; [https://rosettacode.org/wiki/Farey_sequence Farey sequence] &nbsp; &nbsp; &nbsp; (It concerns fractions.)
;References:
:* &nbsp; Wikipedia entry: &nbsp; [https://en.wikipedia.org/wiki/Fraction_(mathematics)#Proper_and_improper_fractions proper and improper fractions].
:* &nbsp; Wikipedia entry: &nbsp; [https://en.wikipedia.org/wiki/Anomalous_cancellation anomalous cancellation and/or accidental cancellation].
<br><br>