Page 47 - MATINF Nr. 7
P. 47
Mult , imi legate 47
legate de ordin k. Deasemenea n-cuvinte legate de ordin k se mai pot obt , ine s , i dac˘a, pentru
3 ≤ i ≤ k + 2, complet˘am pozit , iile (k + 2), ..., (k + i) cu 1, except , ie f˘acˆand ultima pozit , ie, care
se va completa cu 0 iar ˆın restul pozit , iilor se vor pune n − 2k − i-cuvinte legate de ordin k.
Num˘arul total al acestor n-cuvinte legate de ordin k care se obt , in prin acest procedeu, fiind
egal cu L k + L k + ... + L k n−2k−2 , deducem relat , ia de recurent , ˘a din enunt , .
n−k−3
n−k−4
Observat ,ia 4. Pentru k = 1 se obt , ine recurent , a de la (1) iar pentru k = 2 se obt , ine recurent , a de
la (2)
Listingul pentru funct , iile create ˆın Excel este urm˘atorul:
Public N As Integer
Public B(0 To 50) As Integer
Public NrSbm As Long
Public Function CalcSbm1(k As Integer) As Integer
Dim Max As Long
Dim Cont As Long
N=k
Max=1
For i=1 To N
Max=Max * 2
Next i
NrSbm=Max
For Cont=1 To Max
Bin Cont-1
For i=1 To N
If (B(i-1)=0) And (B(i)=1) And (B(i+1)=0) Then
NrSbm=NrSbm-1
Exit For
End If
Next i
Next Cont
CalcSbm1=NrSbm
End Function
Public Function CalcSbm2(k As Integer) As Integer
Dim Max As Long
Dim Cont As Long
N=k
Max=1
For i=1 To N
Max=Max * 2
Next i
NrSbm=Max
For Cont=1 To Max
Dim Cond1, Cond2 As Boolean
Bin Cont-1
For i=1 To N
Cond1=(B(i-1)=0) And (B(i)=1) And (B(i+1)=0)
Cond2=(B(i-1)=0) And (B(i)=1) And (B(i+1)=1) And (B(i+2)=0)
If Cond1 Or Cond2 Then
NrSbm=NrSbm-1
Exit For
End If
Next i
Next Cont