Logo

Programming-Idioms

History of Idiom 31 > diff from v69 to v70

Edit summary for version 70 by zqwnvl:
[VB] Obey Option Strict

Version 69

2021-08-16, 04:12:21

Version 70

2021-08-19, 04:56:30

Idiom #31 Recursive factorial (simple)

Create recursive function f which returns the factorial of non-negative integer i, calculated from f(i-1)

Idiom #31 Recursive factorial (simple)

Create recursive function f which returns the factorial of non-negative integer i, calculated from f(i-1)

Variables
f,i
Variables
f,i
Code
Function f(i As Integer)
    Return If(i = 0, 1, i * f(i - 1))
End Function
Code
Function f(i As Integer) As Integer
    Return If(i = 0, 1, i * f(i - 1))
End Function
Demo URL
https://sharplab.io/#gist:9da975a4db9089cb2832eb8b570678bf
Demo URL
https://sharplab.io/#gist:9da975a4db9089cb2832eb8b570678bf