diff --git a/cmd/divisors.go b/cmd/divisors.go
index 06c255e..3d9f631 100644
--- a/cmd/divisors.go
+++ b/cmd/divisors.go
@@ -22,7 +22,7 @@ import (
"os"
"github.com/spf13/cobra"
- "scm.dairydemon.net/filifa/mathtools/internal/lib"
+ "scm.dairydemon.net/filifa/mathtools/internal/lib/sieve"
)
var divisorsN uint
@@ -32,7 +32,7 @@ func divisors(cmd *cobra.Command, args []string) {
bufStdout := bufio.NewWriter(os.Stdout)
defer bufStdout.Flush()
- ch := lib.DivisorsSieve(divisorsN, divisorsE, 1000)
+ ch := sieve.DivisorsSieve(divisorsN, divisorsE, 1000)
for i := 0; ; i++ {
v, ok := <-ch
if !ok {
diff --git a/cmd/mobius.go b/cmd/mobius.go
index 4bd7bdd..3387a40 100644
--- a/cmd/mobius.go
+++ b/cmd/mobius.go
@@ -22,7 +22,7 @@ import (
"os"
"github.com/spf13/cobra"
- "scm.dairydemon.net/filifa/mathtools/internal/lib"
+ "scm.dairydemon.net/filifa/mathtools/internal/lib/sieve"
)
var mobiusN uint
@@ -31,7 +31,7 @@ func mobius(cmd *cobra.Command, args []string) {
bufStdout := bufio.NewWriter(os.Stdout)
defer bufStdout.Flush()
- ch := lib.MobiusSieve(mobiusN, 1000)
+ ch := sieve.MobiusSieve(mobiusN, 1000)
for i := 0; ; i++ {
v, ok := <-ch
if !ok {
diff --git a/cmd/primeOmega.go b/cmd/primeOmega.go
index 3a76e46..4d9ff7b 100644
--- a/cmd/primeOmega.go
+++ b/cmd/primeOmega.go
@@ -22,7 +22,7 @@ import (
"os"
"github.com/spf13/cobra"
- "scm.dairydemon.net/filifa/mathtools/internal/lib"
+ "scm.dairydemon.net/filifa/mathtools/internal/lib/sieve"
)
var primeOmegaN uint
@@ -32,7 +32,7 @@ func primeOmega(cmd *cobra.Command, args []string) {
bufStdout := bufio.NewWriter(os.Stdout)
defer bufStdout.Flush()
- ch := lib.PrimeOmegaSieve(primeOmegaN, primeOmegaMul, 1000)
+ ch := sieve.PrimeOmegaSieve(primeOmegaN, primeOmegaMul, 1000)
for i := 0; ; i++ {
v, ok := <-ch
if !ok {
diff --git a/cmd/radical.go b/cmd/radical.go
index e6621e8..1e32136 100644
--- a/cmd/radical.go
+++ b/cmd/radical.go
@@ -22,7 +22,7 @@ import (
"os"
"github.com/spf13/cobra"
- "scm.dairydemon.net/filifa/mathtools/internal/lib"
+ "scm.dairydemon.net/filifa/mathtools/internal/lib/sieve"
)
var radicalN uint
@@ -31,7 +31,7 @@ func radical(cmd *cobra.Command, args []string) {
bufStdout := bufio.NewWriter(os.Stdout)
defer bufStdout.Flush()
- ch := lib.RadicalSieve(radicalN, 1000)
+ ch := sieve.RadicalSieve(radicalN, 1000)
for i := 0; ; i++ {
v, ok := <-ch
if !ok {
diff --git a/cmd/totient.go b/cmd/totient.go
index f1d9afd..5e7e912 100644
--- a/cmd/totient.go
+++ b/cmd/totient.go
@@ -22,7 +22,7 @@ import (
"os"
"github.com/spf13/cobra"
- "scm.dairydemon.net/filifa/mathtools/internal/lib"
+ "scm.dairydemon.net/filifa/mathtools/internal/lib/sieve"
)
var totientN uint
@@ -31,7 +31,7 @@ func totient(cmd *cobra.Command, args []string) {
bufStdout := bufio.NewWriter(os.Stdout)
defer bufStdout.Flush()
- for v := range lib.TotientSieve(totientN, 1000) {
+ for v := range sieve.TotientSieve(totientN, 1000) {
if v == 0 {
continue
}
diff --git a/internal/lib/divisors.go b/internal/lib/sieve/divisors.go
similarity index 98%
rename from internal/lib/divisors.go
rename to internal/lib/sieve/divisors.go
index 4bc5840..2822277 100644
--- a/internal/lib/divisors.go
+++ b/internal/lib/sieve/divisors.go
@@ -14,7 +14,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
-package lib
+package sieve
func pow(base uint, exp uint) uint {
result := uint(1)
@@ -42,6 +42,7 @@ 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]
diff --git a/internal/lib/mobius.go b/internal/lib/sieve/mobius.go
similarity index 98%
rename from internal/lib/mobius.go
rename to internal/lib/sieve/mobius.go
index bf183b8..e5419e1 100644
--- a/internal/lib/mobius.go
+++ b/internal/lib/sieve/mobius.go
@@ -14,7 +14,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
-package lib
+package sieve
/*
MobiusSieve computes mobius(k) for k=1 to n, where mobius is the Mobius function.
diff --git a/internal/lib/primeOmega.go b/internal/lib/sieve/primeOmega.go
similarity index 99%
rename from internal/lib/primeOmega.go
rename to internal/lib/sieve/primeOmega.go
index f3f7a63..8901560 100644
--- a/internal/lib/primeOmega.go
+++ b/internal/lib/sieve/primeOmega.go
@@ -14,7 +14,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
-package lib
+package sieve
func primeOmegaUpdateMultiples(sieve []uint, p uint, n uint, multiplicity bool) {
for q := p; ; q *= p {
diff --git a/internal/lib/radical.go b/internal/lib/sieve/radical.go
similarity index 99%
rename from internal/lib/radical.go
rename to internal/lib/sieve/radical.go
index 1be777f..a61d841 100644
--- a/internal/lib/radical.go
+++ b/internal/lib/sieve/radical.go
@@ -14,7 +14,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
-package lib
+package sieve
func radicalUpdateMultiples(sieve []uint, p uint, n uint) {
for q := p; ; q *= p {
diff --git a/internal/lib/totient.go b/internal/lib/sieve/totient.go
similarity index 98%
rename from internal/lib/totient.go
rename to internal/lib/sieve/totient.go
index 7fbb0ee..ffacde8 100644
--- a/internal/lib/totient.go
+++ b/internal/lib/sieve/totient.go
@@ -14,7 +14,7 @@ GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see .
*/
-package lib
+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.