Program Mencari Bilangan Prima

Mencari bilangan prima












Codingnya :

Private Sub Proses_Click()
If Val(Angka.Text) = 1 Then
Hasil.Caption = "Bukan Prima"
ElseIf Val(Angka.Text) = 2 Then
Hasil.Caption = "Prima"
Else
For i = 2 To Val(Text1.Text) - 1
If Val(Angka.Text) Mod i = 0 Then
Hasil.Caption = "Bukan Prima"
Exit For
Else
Hasil.Caption = "Prima"
End If
Next
End If
Ulang.Enabled = True
Proses.Enabled = False
End Sub

No comments:

Post a Comment