A fraction represents a part of a whole.

A fraction consists of a numerator displayed above a line, and a denominator below.


Multiplying a number by a fraction, is the same as adding the prime numerators and subtracting the prime denominators. For example, multiplying 18, which is made of 2^1 x 3^2, by 2/3 means incrementing prime 2, and decrementing the prime 3, or 2^2 x 3^1.

To experiment with primes, have a look at Fractran.


Dividing the numerator and denominator of a fraction by the same non-zero number yields an equivalent fraction: if the numerator and the denominator of a fraction are both divisible by a number (called a factor) greater than 1, then the fraction can be reduced to an equivalent fraction with a smaller numerator and a smaller denominator.

Subtraction Method

function gcd(a, b)
	if b = 0
		return a
		return gcd(b, a mod b)

Recursive Method

function gcd(a, b)
	if b = 0
		return a
		return gcd(b, a mod b)


Comparing fractions with the same positive denominator yields the same result as comparing the numerators.


To add fractions containing unlike quantities , it is necessary to convert all amounts to like quantities.

1/4 + 1/3
1*3/4*3 + 1*4/3*4
3/12 + 4/12 = 7/12

The process for subtracting fractions is, in essence, the same as that of adding them: find a common denominator, and change each fraction to an equivalent fraction with the chosen common denominator.


To multiply fractions, multiply the numerators and multiply the denominators.

2/3 * 3/4 = 6/12