Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
33
Task/Tau-function/Dyalect/tau-function.dyalect
Normal file
33
Task/Tau-function/Dyalect/tau-function.dyalect
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
func divisorCount(number) {
|
||||
var n = number
|
||||
var total = 1
|
||||
|
||||
while (n &&& 1) == 0 {
|
||||
total += 1
|
||||
n >>>= 1
|
||||
}
|
||||
|
||||
var p = 3
|
||||
while p * p <= n {
|
||||
var count = 1
|
||||
while n % p == 0 {
|
||||
count += 1
|
||||
n /= p
|
||||
}
|
||||
total *= count
|
||||
p += 2
|
||||
}
|
||||
|
||||
if n > 1 {
|
||||
total *= 2
|
||||
}
|
||||
|
||||
total
|
||||
}
|
||||
|
||||
let limit = 100
|
||||
print("Count of divisors for the first \(limit) positive integers:")
|
||||
for n in 1..limit {
|
||||
print(divisorCount(number: n).ToString().PadLeft(2, ' ') + " ", terminator: "")
|
||||
print() when n % 20 == 0
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue