# decomposeFraction -- decompose a rational number

## Synopsis

• Usage:
(a, b, c) = decomposeFraction(p, t)
• Inputs:
• p, an integer, a prime
• t, , the fraction to be decomposed
• Optional inputs:
• NoZeroC => , default value false, forces the returned c to not be zero
• Outputs:
• , containing integers a, b, and c, with b and c nonnegative, such that t = a/(p^b(p^c-1))

## Description

Given a rational number $t$ and a prime $p$, decomposeFraction(p, t) returns a sequence ($a$,$b$,$c$) of integers, with $b$ and $c$ nonnegative, such that $t = a/(p^b(p^c-1))$.

 i1 : (a, b, c) = decomposeFraction(3, 4/45) o1 = (64, 2, 4) o1 : Sequence i2 : 4/45 == a/(3^b * (3^c - 1)) o2 = true

If the number $t$ is of the form $a/p^b$, then the function returns ($a$,$b$,$0$). Setting the option NoZeroC => true forces the third entry of the output sequence to be nonzero, even if that means increasing the first entry.

 i3 : decomposeFraction(3, 4/27) o3 = (4, 3, 0) o3 : Sequence i4 : (a, b, c) = decomposeFraction(3, 4/27, NoZeroC => true) o4 = (8, 3, 1) o4 : Sequence i5 : 4/27 == a/(3^b * (3^c - 1)) o5 = true

## Ways to use decomposeFraction :

• "decomposeFraction(ZZ,QQ)"
• "decomposeFraction(ZZ,ZZ)"

## For the programmer

The object decomposeFraction is .