pascal.bas

#359
Raw
Author
winny
Created
April 23, 2021, 6:14 p.m.
Expires
Never
Size
519 bytes
Hits
263
Syntax
BBC Basic
Private
No
   1 REM TODO PRINT OUT PASCAL'S TRIANGLE 
  50 PRINT "DEPTH??"
  51 INPUT K
 100 FOR I=0 TO K-1 
 105 FOR J=0 TO I 
 110 A=I
 115 B=J
 120 GOSUB 1800 
 130 PRINT A; 
 131 IF J <> I THEN 135 
 132 PRINT
 135 NEXT J 
 140 NEXT I 
1000 GOTO 2000
1699 REM FACTORIAL: A -> A
1700 Z=1
1705 FOR X=1 TO A 
1710 Z=Z*X
1715 NEXT X 
1717 A=Z
1720 RETURN 
1799 REM BINOMIAL: A B -> A 
1800 Y=A-B
1810 GOSUB 1700 
1820 W=A
1830 A=B
1840 GOSUB 1700 
1850 V=A
1860 A=Y
1870 GOSUB 1700 
1890 A=W/(V*A)
1895 RETURN 
2000 END