Initial data commit
This commit is contained in:
parent
72d218235f
commit
f23f22d71c
199087 changed files with 3378941 additions and 0 deletions
43
Task/M-bius-function/FutureBasic/m-bius-function.basic
Normal file
43
Task/M-bius-function/FutureBasic/m-bius-function.basic
Normal file
|
|
@ -0,0 +1,43 @@
|
|||
local fn IsPrime( n as long ) as BOOL
|
||||
BOOL result = YES
|
||||
long i
|
||||
|
||||
if ( n < 2 ) then result = NO : exit fn
|
||||
for i = 2 to n + 1
|
||||
if ( i * i <= n ) and ( n mod i == 0 )
|
||||
result = NO : exit fn
|
||||
end if
|
||||
next
|
||||
end fn = result
|
||||
|
||||
local fn Mobius( n as long ) as long
|
||||
long i, p = 0, result = 0
|
||||
|
||||
if ( n == 1 ) then result = 1 : exit fn
|
||||
for i = 1 to n + 1
|
||||
if ( n mod i == 0 ) and ( fn IsPrime( i ) == YES )
|
||||
if ( n mod ( i * i ) == 0 )
|
||||
result = 0 : exit fn
|
||||
else
|
||||
p++
|
||||
end if
|
||||
end if
|
||||
next
|
||||
if( p mod 2 != 0 )
|
||||
result = -1
|
||||
else
|
||||
result = 1
|
||||
end if
|
||||
end fn = result
|
||||
|
||||
window 1, @"Möbius function", (0,0,600,300)
|
||||
|
||||
printf @"First 100 terms of Mobius sequence:"
|
||||
|
||||
long i
|
||||
for i = 1 to 100
|
||||
printf @"%2ld\t", fn Mobius(i)
|
||||
if ( i mod 20 == 0 ) then print
|
||||
next
|
||||
|
||||
HandleEvents
|
||||
Loading…
Add table
Add a link
Reference in a new issue