move sieves to subpackage

This commit is contained in:
filifa
2025-10-07 17:23:16 -04:00
parent 03e463b7a6
commit a9c7f8091b
10 changed files with 16 additions and 15 deletions

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
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]

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
package lib
package sieve
/*
MobiusSieve computes mobius(k) for k=1 to n, where mobius is the Mobius function.

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
package lib
package sieve
func primeOmegaUpdateMultiples(sieve []uint, p uint, n uint, multiplicity bool) {
for q := p; ; q *= p {

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
package lib
package sieve
func radicalUpdateMultiples(sieve []uint, p uint, n uint) {
for q := p; ; q *= p {

View File

@@ -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 <http://www.gnu.org/licenses/>.
*/
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.