Data commit
This commit is contained in:
parent
7387c8f97b
commit
cb5bb5e222
199093 changed files with 3378972 additions and 0 deletions
34
Task/Mertens-function/FreeBASIC/mertens-function.basic
Normal file
34
Task/Mertens-function/FreeBASIC/mertens-function.basic
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
function padto( i as ubyte, j as integer ) as string
|
||||
return wspace(i-len(str(j)))+str(j)
|
||||
end function
|
||||
|
||||
dim as integer M( 1 to 1000 ), n, col, k, psum
|
||||
dim as integer num_zeroes = 0, num_cross = 0
|
||||
dim as string outstr
|
||||
|
||||
M(1) = 1
|
||||
for n = 2 to 1000
|
||||
psum = 0
|
||||
for k = 2 to n
|
||||
psum += M(int(n/k))
|
||||
next k
|
||||
M(n) = 1 - psum
|
||||
if M(n) = 0 then
|
||||
num_zeroes += 1
|
||||
if M(n-1)<>0 then
|
||||
num_cross += 1
|
||||
end if
|
||||
end if
|
||||
next n
|
||||
|
||||
print using "There are ### zeroes in the range 1 to 1000."; num_zeroes
|
||||
print using "There are ### crossings in the range 1 to 1000."; num_cross
|
||||
print "The first 100 Mertens numbers are: "
|
||||
|
||||
for n=1 to 100
|
||||
outstr += padto(3, M(n))+" "
|
||||
if n mod 10 = 0 then
|
||||
print outstr
|
||||
outstr = ""
|
||||
end if
|
||||
next n
|
||||
Loading…
Add table
Add a link
Reference in a new issue