Preloader

Example

The example below demonstrates how the Leibniz series can be implemented with SquareBracket.

                    
                        # Calculator for the Leibniz series

                        print ["Calculating Pi with Leibniz"]

                        mvar denominator pi addto n 1
                        set n args[0]
                        
                        loop n do [
                            set denominator (denominator + 4)
                            set addto (addto - (1/(denominator-2)) + (1/(denominator)))
                        ]
                        
                        set pi (addto * 4)
                        printv pi
                        newl