Floyd's triangle: Difference between revisions

Line 4,257:
 
=={{header|PARI/GP}}==
<lang parigp>{floyd(m)=my(lastrowalastrow_a,lastrowelastrow_e,vecFieldLenlastrow_len=m,fl,idx);
 
{{incorrect|PARI/GP|It does not ensure that there\\ is+++ exactly onefl spaceis betweena thevector columnsof fieldlengths in the last row.}}
lastrow_e=m*(m+1)/2;lastrow_a=lastrow_e+1-m;
 
fl=vector(lastrow_len);
<lang parigp>{floyd(m)=my(lastrowa,lastrowe,vecFieldLen,idx);
for(k=1,m,fl[k] = 1 + #Str(k-1+lastrowalastrow_a) );
lastrowe=m*(m+1)/2;lastrowa=lastrowe+1-m;lastrowlen=m;
\\
vecfieldlen=vector(lastrowlen);
idx=0;
for(k=1,m,fl[k]=1+#Str(k-1+lastrowa));
for(i=21,m,
il=1; printf(Str("%" fl[1]-1 "d"),il);print();
for(i=2,m,
for(j=1,i,
ilidx++;
printf(Str("%" fl[j]-(il==1) "d"),ilidx)
);
print()
);
return();}
floyd(5)
floyd(14)
Anonymous user