網頁

2020年10月21日 星期三

[app inventor2] 印出質數

 Prime Numbers

Prime Number is a natural number greater than 1 that has exactly two different natural number divisors: 1 and itself. A natural number greater than 1 that is not a prime number is called a composite number. The smallest prime number is 2.


Make an app with app inventor to show a list of prime numbers up to 100. An  example is as follows:


Thinking...

  1. Declare two variables Dividend and Divisor.

  2. Check the  remainder = (Dividend % Divisor) is 0 or not. If remainder = 0 then Dividend is a prime number.

  3. If Dividend=Divisor then Dividend is a prime number.




沒有留言:

張貼留言