diff options
| author | Michael Manring <michael@manring> | 2022-07-30 00:38:14 +0700 |
|---|---|---|
| committer | Michael Manring <michael@manring> | 2022-07-30 00:38:14 +0700 |
| commit | 9d8f405bf4752d438c907566967489fb5785be9f (patch) | |
| tree | 383208c7c7534fe0b8830aaa8b9d31f96aadf2b4 | |
| parent | f54a0279ce01c97651be9ea5597c5d672b34f049 (diff) | |
| download | perlweeklychallenge-club-9d8f405bf4752d438c907566967489fb5785be9f.tar.gz perlweeklychallenge-club-9d8f405bf4752d438c907566967489fb5785be9f.tar.bz2 perlweeklychallenge-club-9d8f405bf4752d438c907566967489fb5785be9f.zip | |
pwc175 solution in go - simplified task#2
| -rw-r--r-- | challenge-175/pokgopun/go/ch-2.go | 16 |
1 files changed, 5 insertions, 11 deletions
diff --git a/challenge-175/pokgopun/go/ch-2.go b/challenge-175/pokgopun/go/ch-2.go index 51106c56a2..a94463d9b3 100644 --- a/challenge-175/pokgopun/go/ch-2.go +++ b/challenge-175/pokgopun/go/ch-2.go @@ -12,6 +12,7 @@ Output package main import ( + "fmt" "io" "os" "strconv" @@ -21,18 +22,11 @@ import ( ) func main() { - var cntdwn uint = 20 - p := totient.New(cntdwn) + var count, start uint64 = 20, 3 + fmt.Sscanf(strings.Join(os.Args[1:], " "), "%d %d", &count, &start) var b strings.Builder - for i := uint(3); i < 200_000; i += 2 { - if p.IsPerfect(i) { - b.WriteString(", " + strconv.FormatUint(uint64(i), 10)) - //fmt.Println(i) - cntdwn-- - } - if cntdwn == 0 { - break - } + for _, v := range totient.New().ListPerfect(start, count) { + b.WriteString(", " + strconv.FormatUint(v, 10)) } io.WriteString(os.Stdout, (b.String()[2:])+"\n") } |
