Module Module1
Sub Main()
Dim a, b, i, j As Double
Console.WriteLine("Program Deret Bilangan Prima")
'Algoritma Random input prima
Randomize()
Dim up As Integer = 5
Dim res As Integer = CInt(Int((up * Rnd())) + 1)
Console.WriteLine("input :" & res)
'Algoritma Random bnyak prima
For a = 1 To res
Randomize()
Dim upp As Integer = 20
Dim res2 As Integer = CInt(Int((upp * Rnd())) + 1)
Console.WriteLine("output :" & res2)
i = 1
While i <= res2
b = 0
For j = 1 To i
If i Mod j = 0 Then
b += 1
End If
Next
If b = 2 Then
Console.Write(i & " ")
Else
res2 += 1
End If
i += 1
End While
Console.WriteLine()
Next a
Console.WriteLine()
Console.ReadLine()
End Sub
End Module
hasil dari program diatas :
semoga bermanfaat :)
READMORE
Sub Main()
Dim a, b, i, j As Double
Console.WriteLine("Program Deret Bilangan Prima")
'Algoritma Random input prima
Randomize()
Dim up As Integer = 5
Dim res As Integer = CInt(Int((up * Rnd())) + 1)
Console.WriteLine("input :" & res)
'Algoritma Random bnyak prima
For a = 1 To res
Randomize()
Dim upp As Integer = 20
Dim res2 As Integer = CInt(Int((upp * Rnd())) + 1)
Console.WriteLine("output :" & res2)
i = 1
While i <= res2
b = 0
For j = 1 To i
If i Mod j = 0 Then
b += 1
End If
Next
If b = 2 Then
Console.Write(i & " ")
Else
res2 += 1
End If
i += 1
End While
Console.WriteLine()
Next a
Console.WriteLine()
Console.ReadLine()
End Sub
End Module
hasil dari program diatas :
semoga bermanfaat :)