---
# System prepended metadata

title: Untitled

---


#302 27號 蕭文馨
## 判斷n是否為2的倍數
```python=
import random
n = random.randint(1,100)
i=0
while  (i < n):
  if (n % 2 == 0):
    print("%d是2的倍數" % n)
  i=i+1
```
![](https://i.imgur.com/m9voKhb.png)



## 判斷n為i的倍數
```python=
import random
n = random.randint(1,100)
i=0
while  (i < n):
  if (n % i == 0):
    print("%d是%d的倍數" % (n,i))
  i=i+1
```
![](https://i.imgur.com/n3p7fiM.png)



## 小於等於n的正整數中，3的倍數有幾個
```python=
import random
n = random.randint(1,100)
i=0
acount=0
while  (i <= n):
  if (n % 3 == 0):
   acount=acount+1
  i=i+1
print("%d是3的倍數有%d個" % (n,acount))
```
![](https://i.imgur.com/GJaDDvv.png)


## 判斷n是否為質數
```python=
import random
n = random.randint(1,100)
i=0
while  (i < n):
  if (n % 2!=0):
    print("%d是質數" % (n)) 
  i=i+1
```
![](https://i.imgur.com/pyOEGCH.png)


