- Home
·
- Math/Dates
·
- Calculates the prime factors of a number (e.g. 60 = 2 x 2 x 3 x 5)
Calculates the prime factors of a number (e.g. 60 = 2 x 2 x 3 x 5)
Calculates the prime factors of a number (e.g. 60 = 2 x 2 x 3 x 5)
API Declarations
intNumber is the input number e.g. 60
Rate Calculates the prime factors of a number (e.g. 60 = 2 x 2 x 3 x 5)
(2(2 Vote))
if (isNumeric(intNumber)= true) then
i=0
newn = intNumber
while (newn<>1)
j=2
flag = 1
while ((j<=newn) and (flag=1))
if (newn mod j = 0) then
intPrim = intPrim & j & ","
newn = newn/j
i=i+1
flag = 0
else
j=j+1
end if
wend
wend
if intPrim <> "" then intPrim = Left(intPrim,Len(intPrim)-1)
arrPrim = Split(intPrim,",")
for i=0 to ubound(arrPrim)
if i=0 then
strPrim = arrPrim(i)
else
strPrim = strPrim & " X " & arrPrim(i)
end if
next
end if
Calculates the prime factors of a number (e.g. 60 = 2 x 2 x 3 x 5) Comments
No comments yet — be the first to post one!
Post a Comment