VB.Net Program to Find Factorial of given Number
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
Module Module1 Sub Main() Dim num As Integer, i As Integer, fact As Integer = 1 Console.WriteLine("www.ProgrammingPosts.blogspot.com") Console.WriteLine(vbLf & " >>VB.Net PROGRAM TO FIND FACTORIAL OF GIVEN NUMBER <<" & vbLf) Console.Write(vbLf & " Enter the Number whose Factorial you want: ") num = Convert.ToInt32(Console.ReadLine()) For i = num To 2 Step -1 'i is intializing with num value and is decremented till 2 'fact is updating with changing value of i fact = fact * i Next Console.WriteLine(vbLf & " The factorial of {0} is {1}." & vbLf & vbLf, num, fact) Console.ReadLine() End Sub End Module |
Sample Output :