Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
49
Task/Proper-divisors/Tbas/proper-divisors.tbas
Normal file
49
Task/Proper-divisors/Tbas/proper-divisors.tbas
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
dim _proper_divisors(100)
|
||||
|
||||
sub proper_divisors(n)
|
||||
dim i
|
||||
dim _proper_divisors_count = 0
|
||||
if n <> 1 then
|
||||
for i = 1 to (n \ 2)
|
||||
if n %% i = 0 then
|
||||
_proper_divisors_count = _proper_divisors_count + 1
|
||||
_proper_divisors(_proper_divisors_count) = i
|
||||
end if
|
||||
next
|
||||
end if
|
||||
return _proper_divisors_count
|
||||
end sub
|
||||
|
||||
sub show_proper_divisors(n, tabbed)
|
||||
dim cnt = proper_divisors(n)
|
||||
print str$(n) + ":"; tab(4);"(" + str$(cnt) + " items) ";
|
||||
dim j
|
||||
for j = 1 to cnt
|
||||
if tabbed then
|
||||
print str$(_proper_divisors(j)),
|
||||
else
|
||||
print str$(_proper_divisors(j));
|
||||
end if
|
||||
if (j < cnt) then print ",";
|
||||
next
|
||||
print
|
||||
end sub
|
||||
|
||||
dim i
|
||||
for i = 1 to 10
|
||||
show_proper_divisors(i, false)
|
||||
next
|
||||
|
||||
dim c
|
||||
dim maxindex = 0
|
||||
dim maxlength = 0
|
||||
for t = 1 to 20000
|
||||
c = proper_divisors(t)
|
||||
if c > maxlength then
|
||||
maxindex = t
|
||||
maxlength = c
|
||||
end if
|
||||
next
|
||||
|
||||
print "A maximum at ";
|
||||
show_proper_divisors(maxindex, false)
|
||||
Loading…
Add table
Add a link
Reference in a new issue