Factorize is a function that computes the exponents of each prime in the prime factorization of n
(n int64)
| 8 | // Factorize is a function that computes the exponents |
| 9 | // of each prime in the prime factorization of n |
| 10 | func Factorize(n int64) map[int64]int64 { |
| 11 | result := make(map[int64]int64) |
| 12 | |
| 13 | for i := int64(2); i*i <= n; i += 1 { |
| 14 | for { |
| 15 | if n%i != 0 { |
| 16 | break |
| 17 | } |
| 18 | result[i] += 1 |
| 19 | n /= i |
| 20 | } |
| 21 | |
| 22 | } |
| 23 | if n > 1 { |
| 24 | result[n] += 1 |
| 25 | } |
| 26 | return result |
| 27 | } |
no outgoing calls