Program to find the factorial of a number using foreach extension method in

Posted by Rajnilari2015 under VB.NET category on | Points: 40 | Views : 146
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
Enumerable.Range(1, input).ToList().ForEach(Function(i) fact *= i)

'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