分解质因数-golang
分解质因数-golang
package main
import "fmt"
func main(){
var n int
fmt.Scanf("%d", &n)
for i := 0; i< n;i++{
var num int
fmt.Scanf("%d", &num)
divid(num)
}
}
func divid(x int){
if x < 2{
return
}
for i := 2; i <= x/i; i++{
if x%i==0{
var t int
for x%i == 0{
t++
x /=i
}
fmt.Printf("%d %d\n", i, t)
}
}
if x > 1{
fmt.Printf("%d %d\n", x, 1)
}
fmt.Println()
}