# Function to Check a Fraction for Reducibility

Page 1 of 1

## 0 Replies - 315 Views - Last Post: 06 October 2010 - 01:49 PM

### #1 Brewer

• Awesome

Reputation: 182
• Posts: 1,044
• Joined: 14-June 10

# Function to Check a Fraction for Reducibility

Posted 06 October 2010 - 01:49 PM

Description: Simply insert the snippet into your program. Make sure you call checkReduce(). (No arguments are needed)This snippet contains a function that can check whether or not a simple fraction (of the form x / y) is reducible!
```def checkReduce():
numerator = int(input("Numerator: "))
denominator = int(input("Denominator: "))
smaller = 0
divisor = 0
if numerator < denominator:
smaller = numerator
else:
smaller = denominator
for i in range(2,smaller+1):
if numerator % i == 0 and denominator % i == 0:
divisor = i

if divisor == 0: print("Can not be reduced.")
else: print("%i / %i" % (numerator/divisor, denominator/divisor))
```

Is This A Good Question/Topic? 0

Page 1 of 1

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }