求200 1000之間的所有素數的平方和

2022-02-20 14:32:12 字數 532 閱讀 6543

1樓:

function isprime(byval n as integer) as boolean '是素數返回true,不是素數返回false

dim i as integer

if n < 2 then isprime = false: exit function else isprime = true

for i = 2 to n - 1

if n mod i = 0 then

isprime = false

exit function

end if

next i

end function

private sub command1_click()dim i as long, sum as longfor i = 200 to 300

if isprime(i) then sum = sum + i * i

next

print "200-1000之間的所有素數的平方和=" & sumend sub

程式設計求10 100之間的所有素數之和

沒指定實現語言,用c include int isprime int n int i if n 2 return 0 notif n 2 return 1 yesfor i 2 i void main printf d sum int check int i int m 0 for int j 2 ...

輸出m到n之間的所有素數,包括m和n 100m,n

include int isprime int n for int i 2 i i n i if n i 0 return 0 return n 1 int main int m,n,i scanf d d m,n for i m i n i if isprime i printf d i retu...

求c語言2019到20000之間的素數

include include int isprimer int x return flag void main 呼叫isprimer函式 for i x i y i 鍵盤輸入x和y為 2012和20000!結果是 17029是素數 17033是素數 17041是素數 17047是素數 17053是...