diff --git a/cmd/divisors.go b/cmd/divisors.go index 3d9f631..356e501 100644 --- a/cmd/divisors.go +++ b/cmd/divisors.go @@ -32,7 +32,7 @@ func divisors(cmd *cobra.Command, args []string) { bufStdout := bufio.NewWriter(os.Stdout) defer bufStdout.Flush() - ch := sieve.DivisorsSieve(divisorsN, divisorsE, 1000) + ch := sieve.Divisors(divisorsN, divisorsE, 1000) for i := 0; ; i++ { v, ok := <-ch if !ok { diff --git a/cmd/mobius.go b/cmd/mobius.go index 3387a40..ee59d27 100644 --- a/cmd/mobius.go +++ b/cmd/mobius.go @@ -31,7 +31,7 @@ func mobius(cmd *cobra.Command, args []string) { bufStdout := bufio.NewWriter(os.Stdout) defer bufStdout.Flush() - ch := sieve.MobiusSieve(mobiusN, 1000) + ch := sieve.Mobius(mobiusN, 1000) for i := 0; ; i++ { v, ok := <-ch if !ok { diff --git a/cmd/primeOmega.go b/cmd/primeOmega.go index 4d9ff7b..975548a 100644 --- a/cmd/primeOmega.go +++ b/cmd/primeOmega.go @@ -32,7 +32,7 @@ func primeOmega(cmd *cobra.Command, args []string) { bufStdout := bufio.NewWriter(os.Stdout) defer bufStdout.Flush() - ch := sieve.PrimeOmegaSieve(primeOmegaN, primeOmegaMul, 1000) + ch := sieve.PrimeOmega(primeOmegaN, primeOmegaMul, 1000) for i := 0; ; i++ { v, ok := <-ch if !ok { diff --git a/cmd/radical.go b/cmd/radical.go index 1e32136..e9196d8 100644 --- a/cmd/radical.go +++ b/cmd/radical.go @@ -31,7 +31,7 @@ func radical(cmd *cobra.Command, args []string) { bufStdout := bufio.NewWriter(os.Stdout) defer bufStdout.Flush() - ch := sieve.RadicalSieve(radicalN, 1000) + ch := sieve.Radical(radicalN, 1000) for i := 0; ; i++ { v, ok := <-ch if !ok { diff --git a/cmd/totient.go b/cmd/totient.go index 5e7e912..4c66d0f 100644 --- a/cmd/totient.go +++ b/cmd/totient.go @@ -31,7 +31,7 @@ func totient(cmd *cobra.Command, args []string) { bufStdout := bufio.NewWriter(os.Stdout) defer bufStdout.Flush() - for v := range sieve.TotientSieve(totientN, 1000) { + for v := range sieve.Totient(totientN, 1000) { if v == 0 { continue } diff --git a/internal/lib/sieve/divisors.go b/internal/lib/sieve/divisors.go index 2822277..ae4f05d 100644 --- a/internal/lib/sieve/divisors.go +++ b/internal/lib/sieve/divisors.go @@ -42,7 +42,6 @@ func updateMultiples(sieve []uint, x uint, p uint, n uint) { if p*q >= n { break } - println(q) // sigma_x(p^k) = p^(kx) + sigma_x(p^(k-1)) sieve[p*q] = pow(p*q, x) + sieve[q] @@ -50,9 +49,9 @@ func updateMultiples(sieve []uint, x uint, p uint, n uint) { } /* -DivisorSieve computes sigma_x(k) for k=1 to n, where sigma_x is the divisor sum function. x sets the power each divisor is raised to. +Divisors computes sigma_x(k) for k=1 to n, where sigma_x is the divisor sum function. x sets the power each divisor is raised to. */ -func DivisorsSieve(n uint, x uint, buflen uint) chan uint { +func Divisors(n uint, x uint, buflen uint) chan uint { sieve := make([]uint, n) sieve[0] = 0 for i := uint(1); i < n; i++ { diff --git a/internal/lib/sieve/mobius.go b/internal/lib/sieve/mobius.go index e5419e1..bc0b43d 100644 --- a/internal/lib/sieve/mobius.go +++ b/internal/lib/sieve/mobius.go @@ -17,9 +17,9 @@ along with this program. If not, see . package sieve /* -MobiusSieve computes mobius(k) for k=1 to n, where mobius is the Mobius function. +Mobius computes mobius(k) for k=1 to n, where mobius is the Mobius function. */ -func MobiusSieve(n uint, buflen uint) chan int { +func Mobius(n uint, buflen uint) chan int { sieve := make([]int, n) for i := 0; i < int(n); i++ { sieve[i] = i diff --git a/internal/lib/sieve/primeOmega.go b/internal/lib/sieve/primeOmega.go index 8901560..3b5fade 100644 --- a/internal/lib/sieve/primeOmega.go +++ b/internal/lib/sieve/primeOmega.go @@ -36,9 +36,9 @@ func primeOmegaUpdateMultiples(sieve []uint, p uint, n uint, multiplicity bool) } /* -PrimeOmegaSieve computes omega(k) for k=1 to n, where omega is the prime omega function. If multiplicity is true, factors are counted with multiplicity. +PrimeOmega computes omega(k) for k=1 to n, where omega is the prime omega function. If multiplicity is true, factors are counted with multiplicity. */ -func PrimeOmegaSieve(n uint, multiplicity bool, buflen uint) chan uint { +func PrimeOmega(n uint, multiplicity bool, buflen uint) chan uint { sieve := make([]uint, n) for i := uint(0); i < n; i++ { sieve[i] = 0 diff --git a/internal/lib/sieve/radical.go b/internal/lib/sieve/radical.go index a61d841..e8bb00d 100644 --- a/internal/lib/sieve/radical.go +++ b/internal/lib/sieve/radical.go @@ -35,9 +35,9 @@ func radicalUpdateMultiples(sieve []uint, p uint, n uint) { } /* -RadicalSieve computes rad(k) for k=1 to n, where rad(n) is the radical of n. +Radical computes rad(k) for k=1 to n, where rad(n) is the radical of n. */ -func RadicalSieve(n uint, buflen uint) chan uint { +func Radical(n uint, buflen uint) chan uint { sieve := make([]uint, n) sieve[0] = 0 for i := uint(1); i < n; i++ { diff --git a/internal/lib/sieve/totient.go b/internal/lib/sieve/totient.go index ffacde8..dbaa158 100644 --- a/internal/lib/sieve/totient.go +++ b/internal/lib/sieve/totient.go @@ -17,9 +17,9 @@ along with this program. If not, see . package sieve /* -TotientSieve computes totient(k) for k=1 to n, where totient is Euler's totient function. buflen sets the buffer length of the returned channel. Larger buffer lengths can result in better performance at the cost of higher memory usage. +Totient computes totient(k) for k=1 to n, where totient is Euler's totient function. buflen sets the buffer length of the returned channel. Larger buffer lengths can result in better performance at the cost of higher memory usage. */ -func TotientSieve(n uint, buflen uint) chan uint { +func Totient(n uint, buflen uint) chan uint { totients := make([]uint, n) totients[0] = 0 totients[1] = 1