I'm writing a code to return the prime factors of a number, and it's worked for smaller numbers just fine, but for some reason there is a large number that keeps returning 0 when I know for a fact that there is a remainder.
func primeFactors(n int64) []int64 {
var factorSeq []int64
x := 1 // ignore
for i := 2.0; n > 0.0; {
if checkPrime(i) {
if math.Mod(float64(n), i) == 0.0 {
fmt.Println("Factor", x, ":", i, "=", n/int64(i), "R", math.Mod(float64(n), i))
factorSeq = append(factorSeq, int64(i))
n = n / int64(i)
x++ // ignore
} else {
i++
}
} else if int64(i) > n {
break
} else {
i++
//fmt.Println(i)
}
}
fmt.Println("Prime Factors: ", factorSeq)
return factorSeq
}```
Attached are my outputs: