ªð¦^¦Cªí ¤W¤@¥DÃD µo©«

Åã¥Ü¼Æ­È¤£¸õ®æ

Åã¥Ü¼Æ­È¤£¸õ®æ

½Ð±Ð, ­n¦p¦ó­×§ï, ¿é¥Xªº¼Æ­È¤~¤£·|¸õ®æÅã¥Ü.

Sub hw1()
'3-X¶¡ªº½è¼Æ.
n = Range("E1")
For i = 3 To n
    For j = 2 To n - 1
    p = i Mod j
    If p = 0 Then Exit For
Next j

Cells(j, "a").Value = j
Next i

End Sub

¬¡­¶Ã¯1.zip (11.08 KB)

¬¡­¶Ã¯1.zip (11.08 KB)

¬¡­¶Ã¯1.zip (11.08 KB)

¬¡­¶Ã¯1.zip (11.08 KB)

¬¡­¶Ã¯1.zip (11.08 KB)

fangac

¦^´_ 1# fangsc

Sub hw1()

n = Range("E1")

For i = 3 To n
    For j = 2 To n - 1
    p = i Mod j
    If p = 0 Then Exit For
Next j
If [a1] = "" Then
   [a1] = j
Else
   Cells([a65535].End(3).Row + 1, "a").Value = j
End If
Next i
End Sub

TOP

¦^´_ 2# jcchiang

ÁÂÁ§Aªº¦^ÂÐ.
¦ý¬Orun ¥X¨Óªº¼Æ¦r«Ü©_©Ç
a1: 3
a2: 2
a3: 5
a4: 2
a5: 7
a6: 2
a7: 3
a8: 2
a9: 11
.
.
.
fangac

TOP

¦^´_ 3# fangsc

©p­ì¨Óªºµ{¦¡¥Îj­È·í§@Äæ¦ì¦ì¸m,©Ò¥H­È¬O¶Ã¸õ,¨Ã¤£¬O©¹¤UÄæ¦ì¥hÂ\©ñ
EX:·íi=3 j=3º¡¨¬,¬Ocells(3,"a")=3
·íi=4 j=2º¡¨¬,¬Ocells(2,"a")=2
²Ä¤@µ§©ñ¦b²Ä¤Gµ§¤U­±

TOP

Sub TEST_1()
n = Range("E1")
For i = 3 To n Step 2  '¥i´î¤@¥bªº°j°é
    For j = 2 To n - 1
        P = i Mod j
        If P = 0 And i <> j Then Exit For
    Next j
    If P > 0 Then r = r + 1: Cells(r, 1) = i
Next i
End Sub

§ä½è¼Æªº, ¥igoogle, ¦³§ó¦h®Ä¯à¸û¦nªº¤è¦¡

TOP

©Î¸Õ¸Õ:
Sub TEST_1()
n = Range("E1")
For i = 3 To n Step 2
    For j = 2 To Int(Sqr(i)) + 1
        P = i Mod j
        If P = 0 Then Exit For
    Next j
    If P > 0 Then r = r + 1: Cells(r, 1) = i
Next i
End Sub

TOP

·PÁ¤j®aªº«ü¾É.
fangac

TOP

¦^´_ 5# ­ã´£³¡ªL
¤£¦n·N«ä, ¦A¦¸´£°Ý.
If P > 0 Then r = r + 1: Cells(r, 1) = i
    : «_¸¹ ¬O¦ó§@¥Î? §Ú¦³goole, «_¸¹¬O¥Î¨Ó³s±µ2µ{¦¡½X, ¥H²¤Æµ{¦¡
¦ý¬O¦pªG§â³o¤@¦æª½±µ¤À¦¨2¦æ, ±o¥Xªºµ²ªG¬O¤£¦Pªº.
¦pªG¤£¥Î«_¸¹, ½Ð°Ýµ{¦¡¸Ó¦p¦ó¼g?
fangac

TOP

¦^´_ 8# fangsc

If P > 0 Then r = r + 1: Cells(r, 1) = i

µ¥¦P
If P > 0 Then
r = r + 1
Cells(r, 1) = i
END IF

TOP

¦^´_ 9# ­ã´£³¡ªL
ÁÂÁ§Aªº«ü¾É.
fangac

TOP

        ÀR«ä¦Û¦b : §Ú­Ì³Ì¤jªº¼Ä¤H¤£¬O§O¤H¡D¥i¯à¬O¦Û¤v¡C
ªð¦^¦Cªí ¤W¤@¥DÃD