Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Pascal Triangle
#3
We are not alone.

Code: (Select All)
_Title "Pascal Triangle Aliens Among Us" '2022-10-10 bplus

_Define A-Z As _INTEGER64
Screen _NewImage(500, 500, 32)
_ScreenMove 350, 100

For row = 0 To 20 ' level on pyramind 0 is 1, 1 is 1,1  2 is 1,2,1...
    Print "Row"; row
    For col = 0 To row
        b$ = Dec2Bin$(binom(row, col))
        'Print b$; ",";
        h = (1 + Len(b$)) * 20
        For y = 1 To Len(b$)
            If Mid$(b$, y, 1) = "1" Then Line (250 - 10 * row + col * 20, 500 - h + y * 20)-Step(20, 20), _RGB32(0, 180, 0), BF
        Next
    Next
    Print "press any..."
    Sleep
    Cls
Next

Function binom (n, m)
    binom = fac(n) / (fac(m) * fac((n - m)))
End Function

Function fac (n)
    f = 1
    For i = 1 To n
        f = f * i
    Next
    fac = f
End Function

Function Dec2Bin$ (integerBase10 As _Integer64) 'no more &B because easier to add than to remove
    Dim j As Integer, b$
    If integerBase10 = 0 Then Dec2Bin$ = "0": Exit Function
    While 2 ^ j <= integerBase10
        If (integerBase10 And 2 ^ j) > 0 Then b$ = "1" + b$ Else b$ = "0" + b$
        j = j + 1
    Wend
    Dec2Bin$ = b$
End Function

We have never been alone.
  724  855  599  923  575  468  400  206  147  564  878  823  652  556 bxor cross forever
Reply


Messages In This Thread
Pascal Triangle - by bplus - 11-29-2025, 10:11 PM
RE: Pascal Triangle - by bplus - 11-29-2025, 10:20 PM
RE: Pascal Triangle - by bplus - 11-29-2025, 10:55 PM

Possibly Related Threads…
Thread Author Replies Views Last Post
  Triangle Dissection bplus 1 799 05-05-2022, 04:01 AM
Last Post: Pete

Forum Jump:


Users browsing this thread: 1 Guest(s)