write to program to input that the ending no from the user and display all the prime no according to this number
1
Expert's answer
2012-12-04T09:19:44-0500
Module Module1
Sub Main() Dim n As Integer = 0 Console.Write("Please enter a number larger than two: ") n = Integer.Parse(Console.ReadLine()) For i As Integer = 2 To n Dim prime As Boolean = IsPrime(i) If prime Then Console.Write(i.ToString() + " Prime" + Environment.NewLine()) End If Next
Console.Write("Press any key to exit...") Console.ReadLine() End Sub Private Function IsPrime(ByVal number As Integer) As Boolean If ((number And 1) = 0) Then If (number = 2) Then Return True Else Return False End If End If
For i As Integer = 3 To number Step 2 i *= i If ((number Mod i) = 0) Then Return False End If Next Return number <> 1 End Function
Numbers and figures are an essential part of our world, necessary for almost everything we do every day. As important…
APPROVED BY CLIENTS
"assignmentexpert.com" is professional group of people in Math subjects! They did assignments in very high level of mathematical modelling in the best quality. Thanks a lot
Comments
Leave a comment