Juggler_IN
Active Member
- Joined
- Nov 19, 2014
- Messages
- 358
- Office Version
- 2003 or older
- Platform
- Windows
I am trying to replicate the following code in VBA:
IntPartitions
The equivalent VBA UDF, which is not giving output, is:
Any reason it is only giving the following output =printPartitions(4,4,"") = 1;1;1;1; and not the full set?
IntPartitions
The equivalent VBA UDF, which is not giving output, is:
VBA Code:
Function printPartitions(target As Integer, maxValue As Integer, suffix As String)
If target = 0 Then
printPartitions = suffix
Else
If (maxValue > 1) Then
printPartitions = printPartitions(target, maxValue - 1, suffix)
Debug.Print printPartitions
Else
If (maxValue <= target) Then
printPartitions = printPartitions(target - maxValue, maxValue, maxValue & ";" & suffix)
Debug.Print printPartitions
End If
End If
End If
End Function
Any reason it is only giving the following output =printPartitions(4,4,"") = 1;1;1;1; and not the full set?