Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
28
Task/Tau-function/S-BASIC/tau-function.basic
Normal file
28
Task/Tau-function/S-BASIC/tau-function.basic
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
rem - return the value of n mod m
|
||||
function mod(n, m = integer) = integer
|
||||
end = n - m * (n / m)
|
||||
|
||||
rem - return the tau value (number of divisors) of n
|
||||
function tau(n = integer) = integer
|
||||
var i, t, limit = integer
|
||||
if n < 3 then
|
||||
t = n
|
||||
else
|
||||
begin
|
||||
t = 2
|
||||
limit = (n + 1) / 2
|
||||
for i = 2 to limit
|
||||
if mod(n, i) = 0 then t = t + 1
|
||||
next i
|
||||
end
|
||||
end = t
|
||||
|
||||
rem - test by printing the tau value of the first 100 numbers
|
||||
var i = integer
|
||||
print "Number of divisors for first 100 numbers:"
|
||||
for i = 1 to 100
|
||||
print using "## "; tau(i);
|
||||
if mod(i, 10) = 0 then print
|
||||
next i
|
||||
|
||||
end
|
||||
Loading…
Add table
Add a link
Reference in a new issue