vb.net

Factorial program in VB.NET

Factorial Program in VB.NET:
Factorial, in mathematics, the product of all positive integers less than or equal to a given positive integer and denoted by that integer and an exclamation point. Thus, factorial seven is written 7!, meaning 1 × 2 × 3 × 4 × 5 × 6 × 7.
Factorial of n is the product of all positive descending integers. Factorial of n is denoted by n!. For example:

5!=5*4*3*2*1=120
7!=7*6*5*4*3*2*1=5040

The factorial is generally used in Combinations and Permutations (mathematics).
Let’s see the Factorial program in VB.NET using for loop.

Imports System
Module Program
Sub Main(args As String())
Dim i, number As Integer, fact As Integer = 1
Console.Write(“Enter any Number: “)
number = Integer.Parse(Console.ReadLine())

For i = 1 To number
fact = fact * i
Next

Console.Write(“Factorial of ” & number & ” is: ” & fact)
Console.ReadLine()
End Sub
End Module

Output

factorial-program-in-vb-net

Leave a Reply

Your email address will not be published.