popovIliya

Recursion factorial

Feb 18th, 2021
308
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Module recursion
  2.  
  3.     Function Fact(n)
  4.         If (n <= 1) Then
  5.             Fact = 1
  6.         Else
  7.             Fact = Fact(n - 1) * n
  8.         End If
  9.     End Function
  10.     Sub Main()
  11.         Console.Write("n= ")
  12.         Dim n As Long = CLng(Val(Console.ReadLine()))
  13.         Console.WriteLine(Fact(n))
  14.         Console.ReadKey()
  15.     End Sub
  16.  
  17. End Module
  18.  
Advertisement
Add Comment
Please, Sign In to add comment