Private Sub btnCheck_Click(sender As Object, e As EventArgs) Handles btnCheck.Click Dim num As Integer = Integer.Parse(TextBox1.Text) Dim isPrime As Boolean = True ' Handling numbers less than 2 If num < 2 Then isPrime = False Else For i As Integer = 2 To Math.Sqrt(num) If num Mod i = 0 Then isPrime = False Exit For End If Next End If
Module Module1 Function Factorial(ByVal n As Integer) As Long If n = 0 Or n = 1 Then Return 1 Else Return n * Factorial(n - 1) End If End Function Sub Main() Dim num As Integer Console.Write("Enter a number: ") num = Console.ReadLine() Console.WriteLine("Factorial is: " & Factorial(num)) Console.ReadLine() End Sub















