2005-06-09 09:26:41小海鷗
程設解答
在考竹北高中筆試時...出現這一題...
For x = 2 To 30
For y = 2 To x / 2
flag = 0
If x / y = Int(x / y) Then
flag = 1
End If
Next y
If flag = 0 Then
Print x;
End If
Next x
應該沒有寫錯吧...
回家後一時興起...丟到VB中去跑跑看...
結果是: 2,3,5,7,9,11,13,15,17,19,21,23,25,27,29
本來是想說求奇數的...想不到2也出來亂...
果然是差一題...呵呵~~
For x = 2 To 30
For y = 2 To x / 2
flag = 0
If x / y = Int(x / y) Then
flag = 1
End If
Next y
If flag = 0 Then
Print x;
End If
Next x
應該沒有寫錯吧...
回家後一時興起...丟到VB中去跑跑看...
結果是: 2,3,5,7,9,11,13,15,17,19,21,23,25,27,29
本來是想說求奇數的...想不到2也出來亂...
果然是差一題...呵呵~~