Prime decomposition: Difference between revisions

Content added Content deleted
Line 4,926: Line 4,926:
=={{header|S-BASIC}}==
=={{header|S-BASIC}}==
<lang S-BASIC>
<lang S-BASIC>
rem - compute p mod q
rem - return p mod q
function mod(p, q = integer) = integer
function mod(p, q = integer) = integer
end = p - q * (p/q)
end = p - q * (p/q)
Line 4,935: Line 4,935:
Find the prime factors of n and store in global array factors
Find the prime factors of n and store in global array factors
(arrays cannot be passed as parameters) and return the number
(arrays cannot be passed as parameters) and return the number
found. If n is prime, it will be stored as the one and only
found. If n is prime, it will be stored as the only factor.
factor.
end
end
function primefactors(n = integer) = integer
function primefactors(n = integer) = integer