Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
40
Task/Tau-number/Go/tau-number.go
Normal file
40
Task/Tau-number/Go/tau-number.go
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
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 first 100 tau numbers are:")
|
||||
count := 0
|
||||
i := 1
|
||||
for count < 100 {
|
||||
tf := countDivisors(i)
|
||||
if i%tf == 0 {
|
||||
fmt.Printf("%4d ", i)
|
||||
count++
|
||||
if count%10 == 0 {
|
||||
fmt.Println()
|
||||
}
|
||||
}
|
||||
i++
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue