package main

import (
    "fmt"
    "math/big"
)

func factors(n *big.Int) (fs []big.Int) {
	zero := big.NewInt(0)
    one  := big.NewInt(1)
    two  := big.NewInt(2)
    four := big.NewInt(4)
    six  := big.NewInt(6)
    wheel := [11]*big.Int{one,two,two,four,two,four,two,four,six,two,six}
    w := 0
    f := two
    z := zero
    z.Mul(f, f)
    for z.Cmp(n) <= 0 {
    	fmt.Println(f, n)
    	z.Mod(n, f)
    	for z.Cmp(zero) == 0 {
    		fmt.Println(f, z, n)
    		fs = append(fs, *f)
    		n.Div(n, f)
    		z.Mod(n, f)
    	}
    	f.Add(f, wheel[w])
    	w += 1
    	if w > 11 { w = 3 }
    	z.Mul(f, f)
    }
    fs = append(fs, *n)
    return fs
}

func main() {
	fmt.Println(factors(big.NewInt(13290059)))
}