' Lookup Tables using inline array initialization
#COMPILE EXE
#DIM ALL

FUNCTION PBMAIN() AS LONG
    LOCAL squares(20) AS LONG
    LOCAL cubes(20) AS LONG
    LOCAL fibs(20) AS LONG
    LOCAL primes(20) AS LONG
    LOCAL i AS LONG

    squares(0) = 0: squares(1) = 1: squares(2) = 4: squares(3) = 9: squares(4) = 16
    squares(5) = 25: squares(6) = 36: squares(7) = 49: squares(8) = 64: squares(9) = 81
    squares(10) = 100: squares(11) = 121: squares(12) = 144: squares(13) = 169: squares(14) = 196
    squares(15) = 225: squares(16) = 256: squares(17) = 289: squares(18) = 324: squares(19) = 361
    squares(20) = 400

    cubes(0) = 0: cubes(1) = 1: cubes(2) = 8: cubes(3) = 27: cubes(4) = 64
    cubes(5) = 125: cubes(6) = 216: cubes(7) = 343: cubes(8) = 512: cubes(9) = 729
    cubes(10) = 1000: cubes(11) = 1331: cubes(12) = 1728: cubes(13) = 2197: cubes(14) = 2744
    cubes(15) = 3375: cubes(16) = 4096: cubes(17) = 4913: cubes(18) = 5832: cubes(19) = 6859
    cubes(20) = 8000

    fibs(0) = 0: fibs(1) = 1: fibs(2) = 1: fibs(3) = 2: fibs(4) = 3
    fibs(5) = 5: fibs(6) = 8: fibs(7) = 13: fibs(8) = 21: fibs(9) = 34
    fibs(10) = 55: fibs(11) = 89: fibs(12) = 144: fibs(13) = 233: fibs(14) = 377
    fibs(15) = 610: fibs(16) = 987: fibs(17) = 1597: fibs(18) = 2584: fibs(19) = 4181
    fibs(20) = 6765

    primes(0) = 2: primes(1) = 3: primes(2) = 5: primes(3) = 7: primes(4) = 11
    primes(5) = 13: primes(6) = 17: primes(7) = 19: primes(8) = 23: primes(9) = 29
    primes(10) = 31: primes(11) = 37: primes(12) = 41: primes(13) = 43: primes(14) = 47
    primes(15) = 53: primes(16) = 59: primes(17) = 61: primes(18) = 67: primes(19) = 71
    primes(20) = 73

    PRINT "Lookup Table Demo"
    PRINT "================"
    PRINT ""

    PRINT "Squares (n -> n^2):"
    i = 0
    WHILE i <= 10
        PRINT "  "; i; " -> "; squares(i)
        i = i + 1
    WEND

    PRINT ""
    PRINT "Cubes (n -> n^3):"
    i = 0
    WHILE i <= 10
        PRINT "  "; i; " -> "; cubes(i)
        i = i + 1
    WEND

    PRINT ""
    PRINT "Fibonacci numbers:"
    i = 0
    WHILE i <= 20
        PRINT "  F("; i; ") = "; fibs(i)
        i = i + 1
    WEND

    PRINT ""
    PRINT "Prime numbers:"
    i = 0
    WHILE i <= 20
        PRINT "  Prime #"; i + 1; " = "; primes(i)
        i = i + 1
    WEND

    PRINT ""
    PRINT "Fast lookup verification:"
    PRINT "  squares(10) = "; squares(10); " (expected: 100)"
    PRINT "  cubes(5) = "; cubes(5); " (expected: 125)"
    PRINT "  fibs(10) = "; fibs(10); " (expected: 55)"
    PRINT "  primes(5) = "; primes(5); " (expected: 13)"

    FUNCTION = 0
END FUNCTION
