Compute the prime factors of a given natural number.
A prime number is only evenly divisible by itself and 1.
Note that 1 is not a prime number.
What are the prime factors of 60?
Our successful divisors in that computation represent the list of prime factors of 60: 2, 2, 3, and 5.
You can check this yourself:
2 * 2 * 3 * 5
= 4 * 15
= 60
Success!
Register | Usage | Type | Description |
---|---|---|---|
$a0 |
input | integer | natural number to be factorized |
$a1 |
input/output | address | destination array for prime factors |
$v0 |
output | integer | number of factors |
$t0-9 |
temporary | any | used for temporary storage |
Sign up to Exercism to learn and master MIPS Assembly with 54 exercises, and real human mentoring, all for free.