Wednesday, August 18, 2010

Perl script to print the below triangle pattern

OUTPUT:

1
1 2
1 2 3
1 2 3 4

Program:

#!/depot/perl-5.8.3/bin/perl

foreach (1..4) {
@a=(1..$_);
print "@a \n";
}

No comments:

Post a Comment