HOLA!!!
ACA LES DEJO MI CODE, MEJORE EL DE LEANDRO A (10% mas rapido en promedio):
(seguro que se puede mejorar la parte que agregue)
si se continua expresando como funcion e imprimiendo las celdas negativas se toma menos tiempo.
Private tmr As CTiming
Private Function MatriX7913(ByVal N As Integer) As Long()
Dim M() As Long
Dim x As Integer, y As Integer, Z As Integer
Dim AGRUP As Long, TAM As Integer
If N < 1 Then Exit Function
TAM = N - 1
ReDim M(TAM, TAM)
For x = 0 To TAM
M(x, 0) = x
M(TAM, x) = TAM
If TAM > 0 Then
If Not x = TAM Then
M(x, 1) = 1 + (x * 2)
If x = TAM - 2 Then
For a = 1 To TAM
M(TAM - 1, a) = (TAM * 2) - 1
Next
End If
End If
End If
Next
If TAM > 1 Then
'GRACIAS LEANDRO A
For y = 2 To TAM
For x = 0 To (TAM - 2)
If x + y > TAM Then
M(x, y) = M(x, y - 1)
Else
AGRUP = 0
For Z = x To y + x
AGRUP = AGRUP + M(Z, y - 1)
Next
M(x, y) = AGRUP
End If
Next
Next
'GRACIAS LEANDRO A
End If
MatriX7913 = M
End Function
Private Sub Form_Load()
Dim M() As Long
Dim TAMX As Integer, x As Integer, y As Integer
Set tmr = New CTiming
TAMX = 17
For FAF = 1 To 10
tmr.Reset
M = MatriX7913(TAMX)
MsgBox tmr.sElapsed
Next
For y = 0 To TAMX - 1
For x = 0 To TAMX - 1
Debug.Print M(x, y),
Next
Debug.Print
Next
End Sub
MOD: lo baje a un 15%
GRACIAS POR LEER!!!