If by 'circular reference' you mean recursion, then yes, the calculation of a factorial is ideally suited to this very elegant programming technique.just wanted to check whether we can calculate factorial of a number using circular reference.
Option Explicit
Public Function xFactor(arg As Integer) As Long
If arg = 1 Then
xFactor = 1
Else
xFactor = arg * xFactor(arg - 1)
End If
End Function
Probably not. You would do that using a technique known as 'approximation by iteration', something like this:-what about square root ? can it be done?
Option Explicit
Public Function xSqRoot(arg As Double) As Double
Dim Root1 As Double
Dim Root2 As Double
Dim iLoop As Long
Debug.Print "Square root of" ; arg ; "by iteration"
Root1 = 1
For iLoop = 1 To 20 ' loop as many times as necessary to home in on a number which doesn't change from one loop to the next
Root2 = arg / Root1
Root1 = (Root1 + Root2) / 2
Debug.Print "Loop " ; iLoop ; ": " ; Root1 ' view the immediate window to see this happening
Next iLoop
End Function