47 lines
756 B
Text
47 lines
756 B
Text
|
|
//
|
||
|
|
// Tau Numbers
|
||
|
|
//
|
||
|
|
// FutureBasic 7.0.34, August 2025 R.W
|
||
|
|
//
|
||
|
|
//-------------------------------------
|
||
|
|
//
|
||
|
|
// Given an integer, returns the
|
||
|
|
// Tau positive integer
|
||
|
|
local fn Tau( n as Int) as Int
|
||
|
|
int x, result
|
||
|
|
if n < 3
|
||
|
|
result = n
|
||
|
|
else
|
||
|
|
result = 2
|
||
|
|
for x = 2 to fix((n + 1) / 2)
|
||
|
|
if n % x == 0 then result++
|
||
|
|
next x
|
||
|
|
end if
|
||
|
|
end fn = result
|
||
|
|
|
||
|
|
// Returns True if n is a Tau number
|
||
|
|
local fn isTau(n as Int) as boolean
|
||
|
|
boolean result = _False
|
||
|
|
if n % fn Tau(n) == 0 then result = _True
|
||
|
|
end fn = result
|
||
|
|
|
||
|
|
window 1,@"Tau numbers"
|
||
|
|
|
||
|
|
print
|
||
|
|
print " First 100 Tau numbers:"
|
||
|
|
print
|
||
|
|
|
||
|
|
int x, c, res
|
||
|
|
c = 1: x = 1
|
||
|
|
while c < 100
|
||
|
|
if fn isTau(x)
|
||
|
|
print using "######";x;
|
||
|
|
if (c % 9 == 0) then print
|
||
|
|
c++
|
||
|
|
end if
|
||
|
|
x++
|
||
|
|
wend
|
||
|
|
|
||
|
|
handleEvents
|
||
|
|
//
|