Program to find the factorial of a number using foreach loop in

Posted by Rajnilari2015 under VB.NET category on | Points: 40 | Views : 131
Imports System.Collections.Generic
Imports System.Linq

Namespace ConsoleApplication1
Class Program
Private Shared Sub Main(args As String())
Dim input As Integer = 10
'Factorial of the number to find
Dim fact As Integer = 1
'a temporary variable to store the intermediate computed values
'the computation
For Each number As var In Enumerable.Range(1, input).ToList()
fact *= number

'display the result
Console.WriteLine("Factorial of {0} is {1}", input, fact)
End Sub
End Class
End Namespace

Factorial of 10 is 3628800

Comments or Responses

Login to post response