.
Este codigo sigue la secuencia hasta
n Longitud dada.
Option Explicit
Private Sub Form_Load()
Dim v As Variant
For Each v In iteraccion(20)
Debug.Print v
Next
End Sub
Public Function iteraccion(ByVal llen As Long) As Long()
Dim i As Long
Dim c As Long
Dim t As Long
Dim vares() As Long
llen = (llen - 1)
ReDim vares(0 To llen)
c = 1
For i = 0 To llen Step 5
vares(i) = c: t = i + 1
If (t < llen) Then
vares(t) = 15: t = t + 1
If (t < llen) Then
vares(t) = 10: t = t + 1
If (t < llen) Then
vares(t) = 5: t = t + 1
If (t < llen) Then
vares(t) = 0: c = c + 1
End If
End If
End If
End If
Next i
iteraccion = vares()
End Function
... de una manera mas simple.
Option Explicit
Private Sub Form_Load()
Dim v As Variant
For Each v In iteraccion(21)
Debug.Print v
Next
End Sub
Public Function sets(ByVal lval As Long, ByRef vaArr() As Long, ByVal index As Long, ByVal lub As Long) As Long
If Not ((index And &H80000000) = &H80000000) Then
If (index <= lub) Then
vaArr(index) = lval
sets = (index + 1)
Exit Function
End If
End If
sets = &H80000000
End Function
Public Function iteraccion(ByVal llen As Long) As Long()
Dim i As Long
Dim c As Long
Dim vares() As Long
llen = (llen - 1)
ReDim vares(0 To llen)
c = 1
For i = 0 To llen Step 5
vares(i) = c
sets 5, vares(), sets(10, vares(), sets(15, vares(), (i + 1), llen), llen), llen
c = c + 1
Next i
iteraccion = vares()
End Function
Dulces Lunas!¡.