-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathpascals_triangle.mnd
More file actions
38 lines (31 loc) · 807 Bytes
/
pascals_triangle.mnd
File metadata and controls
38 lines (31 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
#**
* This is code in the Mindcode language
*
* Write this code to compare the differences between various compiler styles.
* As I am a temporary learning Mindcode,
* You can create a PR to fix errors or make it more concise
*#
const TRIANGLE_SIZE = 10;
currentLine = cell1;
previousLine = cell2;
print("1\n1 1\n");
lastSize = 2;
previousLine[0] = 1;
previousLine[1] = 1;
for i in 3...TRIANGLE_SIZE do
currentLine[0] = 1
for j in 1..lastSize do
currentLine[j] = previousLine[j - 1] + previousLine[j];
end;
currentLine[lastSize] = 1;
lastSize += 1;
for c in 0..lastSize do
print(currentLine[c]);
previousLine[c] = currentLine[c];
if c < lastSize - 1 then
print(" ");
end;
end;
print("\n");
end;
printflush(message1);