rational functions · MIT License
Overview
Reduce an integer fraction to lowest terms and normalize a negative denominator.
- Tested on a TI calculator
- Downloaded 46 times
- Version 1.0.0
- 1373 bytes
- No imports
Tried it? Did this program work on your calculator?
Before you run it
- TI-84 Plus CE Python · tested on OS 5.8.3, Python App 5.8.3.0048
- TI Connect CE .py conversion to a Python AppVar in RAM; physically tested one program at a time
- Inputs represent a fraction.
- The denominator cannot be zero.
- Non-integer input is rejected by the calculator conversion.
Try the DuckieDai calculator screen
Follow the reviewed program prompts and calculation flow before downloading.
TI-84 Plus CE Python · screen preview
Learn the math
How reducing a fraction works
The idea
A fraction is in lowest terms when the top and bottom share no factor other than 1. To get there, divide both by their greatest common divisor.
The formula
a/b = (a / gcd)/(b / gcd)
a- numerator
b- denominator, not 0
gcd- the largest whole number that divides both
Using the program
- Enter the numerator and the denominator as whole numbers.
- The program shows the reduced fraction and moves any negative sign to the top.
Worked example
Reduce 18/24. Enter 18 and 24.
gcd(18, 24) = 6, so 18/24 = 3/4
The program shows 3/4.
Doing it by hand
The greatest common divisor is easy to spot for small numbers and hard for large ones. Euclid's algorithm finds it without any guessing: divide the larger number by the smaller, keep the remainder, and repeat with the smaller number and that remainder until the remainder is 0. The last divisor is the greatest common divisor.
Reduce 84/126 this way.
126 = 1 x 84 + 42
84 = 2 x 42 + 0
The last divisor is 42, so divide the top and bottom by 42: 84/126 = 2/3.
Reducing first pays off in later steps. Fractions in lowest terms are easier to compare, and when you add or multiply them the numbers stay small enough to check in your head.
Tips and common mistakes
- Both numbers must be whole numbers.
- The denominator cannot be 0.
- A negative denominator is rewritten: 3/-4 becomes -3/4.
Where this comes up
Reducing fractions is used at every level, from pre-algebra to calculus. It matters most when an answer must be exact and a decimal will not do.
Exact reviewed bytes
Source code
"""DuckieDai Fraction Simplifier for TI-84 Plus CE Python."""def duckiedai_intro(program_name, wait=True):title=program_name[:16]; empty=16-len(title); left=empty//2; right=empty-leftprint("+----------------------+"); print("| "+" "*left+title+" "*right+" |"); print("| |"); print("| __ |"); print("| ___(o )> quack! |"); print("| \\ <_. ) |"); print("| `---' |"); print("| by DuckieDai |"); print("+----------------------+"); print("Loading...")if wait: input("Press enter to start "); print("\n"*8)def clear_screen(): print("\n"*8)def gcd(a,b):a=abs(a); b=abs(b)while b!=0: a,b=b,a%breturn adef run_solver():clear_screen(); print("FRACTION SIMPLIFY"); print("-----------------"); print("")top=int(input("Numerator: ")); bottom=int(input("Denominator: "))if bottom==0: clear_screen(); print("INVALID"); print("Denominator"); print("cannot be 0"); returnif bottom<0: top=-top; bottom=-bottomcommon=gcd(top,bottom); top//=common; bottom//=commonclear_screen(); print("SIMPLIFIED"); print("----------"); print(top if bottom==1 else str(top)+"/"+str(bottom))duckiedai_intro("Fraction Simpl")while True:run_solver(); print("")if input("Again? y/n: ").lower()!="y": breakclear_screen(); print("DuckieDai says: done!")
- Filename
FRCSIM.py- Size
- 1373 bytes
- SHA-256
0171deb2669e9b8c8d0cd2bc2ac46ca48ad63f4f913e5214a6bb81af044da301
Usage
Inputs
- Integer numerator
- Nonzero integer denominator
Outputs
- Fraction in lowest terms
Units: Integers; no physical units.
Assumptions and limitations
Assumptions
- Inputs represent a fraction.
Constraints
- The denominator cannot be zero.
Known failures
- Non-integer input is rejected by the calculator conversion.
Compatibility and review
- Review status
- Tested on a TI calculator
- Tested on
- Creator-owned TI-84 Plus CE Python calculator; exact .py transferred and launched individually
- What happened
- Passed: creator personally tested the exact Fraction Simplifier program on a TI 84 Plus CE Python calculator.
- Dependencies
- No imports
- Suggested calculator name
FRCSIM— you can give it another valid, unique name when you transfer it- Desktop test cases
- Not available for this interactive-only source
This exact source auto-launches an interactive calculator session, so compatibility evidence comes from the recorded physical-device review rather than an importable desktop fixture.
Transfer and launch
Download the .py file, send it to your calculator with TI Connect CE as FRCSIM or another name, then open the Python App and try the worked example on this page first.
Full installation and troubleshooting guide. Check your teacher's or exam's rules before using any program.
Version history
- 1.0.0 — current version, published . Download this reviewed version
Related learning
Did a DuckieDai program help with your homework? Every program here is free. If you would like to say thanks, you can leave a tip on Cash App ($duckiedai214) or read what tips pay for.
Independent compatibility resource: Hidden Word Scanner is independent and is not affiliated with or endorsed by Texas Instruments. TI product names describe compatibility only.
Action-count privacy: Successful downloads, preview starts, and preview completions increment same-origin aggregate counters, and so does a Yes or No answer about whether the program worked. Your browser notes that you answered; that note is never sent to the site. No entered values, source text, IP address, account, cookie, device identifier, or fingerprint is stored with these counts.