Floyd's triangle: Difference between revisions

(Add CLU)
Line 4,260:
{{incorrect|PARI/GP|It does not ensure that there is exactly one space between the columns in the last row.}}
 
<lang parigp>F{floyd(nm)=my(fmt=Str("%"1+#Str(n*(n+1)/2)"d")lastrowa,t);for(i=1lastrowe,nvecFieldLen,for(j=1,i,printf(fmt,t++)idx);print)
lastrowe=m*(m+1)/2;lastrowa=lastrowe+1-m;lastrowlen=m;
F(5)
vecfieldlen=vector(lastrowlen);
F(14)</lang>
for(k=1,m,fl[k]=1+#Str(k-1+lastrowa));
il=1; printf(Str("%" fl[1]-1 "d"),il);print();
for(i=2,m,
for(j=1,i,
il++;
printf(Str("%" fl[j]-(il==1) "d"),il)
);
print()
);
return()}
floyd(5)
floyd(14)
F(14)</lang>
{{out}}
<pre> 1
1
2 3
4 5 6
7 8 9 10
11 12 13 14 15
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 39 40 41 42 43 44 45
46 47 48 49 50 51 52 53 54 55
56 57 58 59 60 61 62 63 64 65 66
67 68 69 70 71 72 73 74 75 76 77 78
79 80 81 82 83 84 85 86 87 88 89 90 91
92 93 94 95 96 97 98 99 100 101 102 103 104 105</pre>
</pre>
 
=={{header|Pascal}}==
Anonymous user