_limit = 100000 Long Q(_limit), i, count = 0 Q(1) = 1 Q(2) = 1 For i = 3 To _limit Q(i) = Q(i-Q(i-1)) + Q(i-Q(i-2)) If Q(i) < Q(i-1) Then count += 1 Next i Print "First 10 elements:"; For i = 1 To 10 Print str$(Q(i)) + " "; Next i Print Print "Q(1000) is "; Q(1000) Print "There were" + str$(count) + " inversions" handleevents