查看單個文章
舊 2007-11-09, 05:18 PM   #1
rang0419
註冊會員
榮譽勳章

勳章總數0
UID - 285008
在線等級: 級別:0 | 在線時長:4小時 | 升級還需:1小時
註冊日期: 2007-11-07
文章: 24
精華: 0
現金: 35 金幣
資產: 35 金幣
預設 請問該如何用C寫呢??



--------------------
閱讀本主題的最佳解答
--------------------


An integer is said to be prime if it is divisible by only 1 and itself. For example, 2, 3, 5, and 7 are prime, but 4, 6, 8 and 9 are not.

1. Write a function that receives a number from the main function and determines if the number is prime.

2.Write the main function that
(a.)reads an integer n and uses the above function to determine and print all the prime numbers between 1 and n.

(b.)calulates the sum of all prime numbers between 1 and n.
A possibe run may look like:

Enter the number: 10
The prime numbers between 1 and 10 are:
2
3
5
7
The sum is 17.
Enter the number: 50
The prime numbers between 1 and 100 are:
2
3
5
7
11
13
17
19
23
29
31
37
41
43
47
The sum is 328.


可以參考一下嗎..........
rang0419 目前離線  
送花文章: 5, 收花文章: 0 篇, 收花: 0 次
回覆時引用此帖