Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
33
Task/Tau-function/Go/tau-function.go
Normal file
33
Task/Tau-function/Go/tau-function.go
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
|
||||
func countDivisors(n int) int {
|
||||
count := 0
|
||||
i := 1
|
||||
k := 2
|
||||
if n%2 == 0 {
|
||||
k = 1
|
||||
}
|
||||
for i*i <= n {
|
||||
if n%i == 0 {
|
||||
count++
|
||||
j := n / i
|
||||
if j != i {
|
||||
count++
|
||||
}
|
||||
}
|
||||
i += k
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
func main() {
|
||||
fmt.Println("The tau functions for the first 100 positive integers are:")
|
||||
for i := 1; i <= 100; i++ {
|
||||
fmt.Printf("%2d ", countDivisors(i))
|
||||
if i%20 == 0 {
|
||||
fmt.Println()
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue