<script language="JavaScript1.1"> <!--- Begin script hiding // Pascal's Triangle generator with variable rows and factor value // written by Stephen Battey - May 1997 // http://www.oocities.org/Heartland/Plains/5287 // Modified in June 1997 by Stephen Battey // Triangle creation process is now done in the background function Round(number) { // function returns the extracted integer part // of a decimal number - Math.round is not used // since it is only availiable on a Unix platform v=number.toString() i=v.indexOf(".") if ( i==-1 ) { return number } else { if ( i==0 ) return 0 else return eval(v.substring(0,i)) } } // Arrays needed for Pascal's triangle function curvals = new Array() ProcessingTri=false function CreateTriangle(dep,fac,pstage) { // Procedure to open a new window with pascal's // triangle of 'dep' lines deep, coloured according // to the factor 'fac' if ( pstage==0 ) { // Check for any current triangle processing if ( ProcessingTri ) return // Open up a window wstr=((dep*2)+75).toString() hstr=((dep*2)+175).toString() trianglewindow = window.open("", "", "toolbar=0 , status=0 , menubar=0, scrollbars=0, resizeable=1, width=" + wstr + ", height=" + hstr) triwin=trianglewindow.document // Setup window html triwin.write("<html><title>Pascals Triangle (Div=" + fac.toString() + ")</title><body bgcolor='#000000' text='#c0c000'><p><br><center>") // Show 'Close window' button triwin.write("<p><font size=2>close this window
before opening a new<br><form><input type='button' value=' CLOSE ' onClick='window.close()'></form><p>") // Initialise triangle ProcessingTri=true TriTimer = window.setTimeout("CreateTriangle("+dep+","+fac+",1)",20) return } if ( pstage>dep ) { // End html text triwin.write("</center></body></html>") triwin.close() ProcessingTri=false return } left = 1 for (j=2; j<=pstage; j++) { right = curvals[j] curvals[j] = left + right left = right } curvals[pstage] = 1 // Produce a row of Pascal's triangle for (j=1; j<=pstage; j++) { if ( Round(curvals[j]/fac)==(curvals[j]/fac) ) cps="WhiteDot" else cps="BlackDot" triwin.write("<img src='"+cps+".jpg'>") } triwin.write("<br>") TriTimer = window.setTimeout("CreateTriangle("+dep+","+fac+","+(pstage+1)+")",10) } // end hiding --> </script>