من المعروف ان الأعداد الأولية لا تنقسم إلا على واحد وعلى نفسها
و قد جئتكم بهذا الكود لأيجاد كل الأعداد الأولية بين رقمين
ارجو ان ينال اعجابكم
()Sub prim_between2
Dim m As Integer, n As Integer, y As Integer, x As Integer
Range("a4:h100").ClearContents
Range("a4:h100").ClearFormats
(m = Cells(1, 2
(n = Cells(1, 4
If m > n Then
Cells(1, 2) = n: Cells(1, 4) = m
End If
r = 4: c = 2
For x = m To n
(y = Int(x ^ 0.5
For i = 2 To y
Do While x Mod i = 0
If x Mod i = 0 Then
GoTo out
End If
Loop
Next i
Cells(r, c) = x
With Cells(r, c).Font
.Bold = True
.Size = 20
End With
(With Cells(r, c).Borders(xlEdgeLeft
.LineStyle = xlDouble
.Color = -16776961
.Weight = xlThick
End With
With Cells(r, c).Borders(xlEdgeTop)
.LineStyle = xlDouble
.Color = -16776961
.Weight = xlThick
End With
(With Cells(r, c).Borders(xlEdgeBottom
.LineStyle = xlDouble
.Color = -16776961
.Weight = xlThick
End With
(With Cells(r, c).Borders(xlEdgeRight
.LineStyle = xlDouble
.Color = -16776961
.Weight = xlThick
End With
(With Cells(r, c
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
End With
c = c + 1
If c > 8 Then
c = 2: r = r + 1
End If
out:
Next x
Cells(1, 2).Select
End Sub
المشكلة في اللغة العربية هي الأقواس