function mc_pi, n, no_loop=no_loop, seed=seed r = 1. ;;; Circle with a unit radius if keyword_set(no_loop) then begin ;to loop or not to loop? That is the Q. ;;; Generate x annd y coordinates as arrays x = randomu(seed, n)*2-r y = randomu(seed, n)*2-r ;;; Check to see how many points are inside the circle w=where((x^2+y^2) le r^2, incirc) endif else begin incirc = 0. for i = 0, n-1 do begin ;;; Generate an x and y point x = randomu(seed)*2-r y = randomu(seed)*2-r ;;; Is it inside the circle? if x^2+y^2 le r^2 then incirc++ endfor endelse ;;; Calculate pi pi = float(incirc)/float(n)*4. return, pi end