diff options
| author | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2023-08-07 15:49:44 -0500 |
|---|---|---|
| committer | Adrien Hopkins <adrien.p.hopkins@gmail.com> | 2023-08-18 14:26:13 -0500 |
| commit | b4bdd6146962d8dde391f09b2cdda9553cb44bde (patch) | |
| tree | 861e0803d0a16c8fb0b65e86c2d98cef632f0cea /radix_info.go | |
| parent | 8c6419bde0cb6893cf7e789c8fceaea5638c95ff (diff) | |
Add list of factors to output
Diffstat (limited to 'radix_info.go')
| -rw-r--r-- | radix_info.go | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/radix_info.go b/radix_info.go index 4067320..770fd42 100644 --- a/radix_info.go +++ b/radix_info.go @@ -4,6 +4,7 @@ import ( "aphopkins/radix_info/factors" "fmt" "os" + "sort" "strconv" ) @@ -12,6 +13,11 @@ func main() { if n, err := strconv.ParseUint(os.Args[1], 0, 0); err == nil { if n > 1 { fmt.Printf("%d = %s\n", n, factors.PrimeFactorize(uint(n))) + n_factors := factors.Factors(uint(n)) + sort.Slice(n_factors, func(i, j int) bool { + return n_factors[i] < n_factors[j] + }) + fmt.Printf("Factors: %v\n", n_factors) } else { fmt.Println("Argument must be an integer above 1.") } |
