Generate Pascal's Triangle

for((r=1;r<10;r++));do v=1;echo -n "$v ";for((c=1;c<$r;c++));do v2=$(($(echo "$v*($r-$c)/$c")));echo -n "$v2 ";v=$v2;done;echo;done
http://en.wikipedia.org/wiki/Pascal%27s_triangle This one's for bartonski. Enjoy. 132 characters. I'm sure we can do better. Note: after row 64 we overflow integer maths.
Sample Output
1 
1 1 
1 2 1 
1 3 3 1 
1 4 6 4 1 
1 5 10 10 5 1 
1 6 15 20 15 6 1 
1 7 21 35 35 21 7 1 
1 8 28 56 70 56 28 8 1 

0
By: flatcap
2011-02-10 18:38:04

What Others Think

ok... you win...
glaudiston · 571 weeks and 2 days ago
For a better formatted output: (ignore the " , is a try to get a correct view in comment.) { y="$({ x="$({ for((r=1;r<10;r++));do v=1;echo -n "$v ";for((c=1;c<$r;c++));do v2=$(($(echo "$v*($r-$c)/$c")));echo -n "$v2 ";v=$v2;done;echo;done; })"; echo -e "$x" | tail -n1; })"; }; echo -e "$x" | while read l; do j=$((1+${#y}-${#l}/2)); echo "$(while ((i++ <= j)); do echo -n " ";done;)$l";done " 1 " 1 1 " 1 2 1 " 1 3 3 1 " 1 4 6 4 1 " 1 5 10 10 5 1 " 1 6 15 20 15 6 1 " 1 7 21 35 35 21 7 1 "1 8 28 56 70 56 28 8 1
glaudiston · 571 weeks and 2 days ago
First time i am facing this same issue,so just click this site and get the one of the simple best solution to find the set this device how do i fix connections for bluetooth audio devices and wireless displays in windows 10 now finally just one a single click this website and learn more about.
KGF123 · 88 weeks and 1 day ago
Surgery is a medical specialty that uses operative manual and instrumental techniques on a patient to investigate or treat a pathological condition such as a disease or injury, to help improve bodily function or appearance or to repair unwanted ruptured areas. MaxRemind top rank medical billing company USA offers surgery medical billing and medical credentialing services to Surgery physicians in all states of USA at lowest rates.
stevematt · 52 weeks ago
One should persistently purchase such course programming that is fitting to his subject. You can visit CheckMyPunctuation.com for making your grammar mistakes correct. the legitimate assessment ought to be blended toward track down the most sensible and sensible to fulfill your academic necessities.
tinakutch · 35 weeks and 3 days ago
The flexibility that is being offered in the electronic sorting everything out development allows a person to sort out his overwhelmed plan for moving in his extra time. If you glancing through such a sorces. Click CheckMySentence.com for getting wonderful info, shocking quality bearing can be gotten considering this diagram.
tinakutch · 35 weeks and 3 days ago
Young person care ponders are telling watchmen that massive toys are monster in the event that they need to improve the youths' mental new unexpected new turn of events. Once visit www.checkpunctuation.com for more info. Particularly as a parent, you need to manage that improvement.
tinakutch · 35 weeks and 3 days ago
Whenever I at whatever point researched such raising stories, I get a titanic heap of good energies and assessments. Click how to remove passive voice for more ideas. It gets me enough motivation to continue to work out.
Ahmed74 · 30 weeks and 4 days ago
?Ashampoo is the mechanical party for such people who love to download dazzling films in the decreased size. Try this how to detect passive voice it will help you a lot. I'm downloading different sorts of movies essentially through this arrangement.?
Ahmed74 · 30 weeks and 4 days ago
seo ]dsj juvdt seo search engine optimization ]dsj lukd seo seo shdj onlhj seo seokar newseo seo websima bartaramouz seo seoword.org seorooz.net seoyab.com seofox seofox.ir seolab.ir seo site ]dsj seo search engine optimization ]dsj search engine optimization seo website ]dsj seo definition ]dsj google seo ]dsj search optimization ]dsj shdj seo shdj search engine optimization seo ]dsj juvdt seo search engine optimization ]dsj lukd seo seo shdj onlhj seo seokar newseo seo websima bartaramouz seo seoword.org seorooz.net seoyab.com seofox seofox.ir seolab.ir seo site ]dsj seo search engine optimization ]dsj search engine optimization seo website ]dsj seo definition ]dsj google seo ]dsj search optimization ]dsj shdj seo shdj search engine optimization seo ]dsj juvdt seo search engine optimization ]dsj lukd seo seo shdj onlhj seo seokar newseo seo websima bartaramouz seo seoword.org seorooz.net seoyab.com seofox seofox.ir seolab.ir seo site ]dsj seo search engine optimization ]dsj search engine optimization seo website ]dsj seo definition ]dsj google seo ]dsj search optimization ]dsj shdj seo shdj search engine optimization seo ]dsj juvdt seo search engine optimization ]dsj lukd seo seo shdj onlhj seo seokar newseo seo websima bartaramouz seo seoword.org seorooz.net seoyab.com seofox seofox.ir seolab.ir seo site ]dsj seo search engine optimization ]dsj search engine optimization seo website ]dsj seo definition ]dsj google seo ]dsj search optimization ]dsj shdj seo shdj search engine optimization
seofox · 12 weeks and 3 days ago
Hi there! Nice stuff, do keep me posted when you post again something like this! Lake City condo for sale
JaydenShaw · 2 weeks and 6 days ago
I wanted to thank you for this great read!! I definitely enjoying every little bit of it I have you bookmarked to check out new stuff you post. 0x0 0x0
zaltovokni · 1 week and 6 days ago
Really I enjoy your site with effective and useful information. It is included very nice post with a lot of our resources.thanks for share. i enjoy this post. pubfilm
JaydenShaw · 1 week and 6 days ago
I learn some new stuff from it too, thanks for sharing your information. ketamine hcl crystal powder
zaltovokni · 1 week and 5 days ago
What a fantabulous post this has been. Never seen this kind of useful post. I am grateful to you and expect more number of posts like these. Thank you very much. small business consulting
JaydenShaw · 1 week and 5 days ago
I am constantly surprised by the amount of information accessible on this subject. What you presented was well researched and well written to get your stand on this over to all your readers. Thanks a lot my dear. betflix gaming
zaltovokni · 1 week and 3 days ago
It is truly a well-researched content and excellent wording. I got so engaged in this material that I couldn’t wait reading. I am impressed with your work and skill. Thanks. where can i get sildenafil tablets online in australia
JaydenShaw · 1 week and 1 day ago
Wow, cool post. I'd like to write like this too - taking time and real hard work to make a great article... but I put things off too much and never seem to get started. Thanks though. start a payment processing company
zaltovokni · 1 week ago
Your content is nothing short of brilliant in many ways. I think this is engaging and eye-opening material. Thank you so much for caring about your content and your readers. wondershare filmora x crack
JaydenShaw · 5 days ago
The writer has outdone himself this time. It is not at all enough; the website is also utmost perfect. I will never forget to visit your site again and again. ??????
zaltovokni · 5 days ago
We have sell some products of different custom boxes.it is very useful and very low price please visits this site thanks and please share this post with your friends. how to get the best cable deal
zaltovokni · 3 days ago
Nice to be visiting your blog again, it has been months for me. Well this article that i’ve been waited for so long. I need this article to complete my assignment in the college, and it has same topic with your article. Thanks, great share. pokerdewa
JaydenShaw · 23 minutes ago

What do you think?

Any thoughts on this command? Does it work on your machine? Can you do the same thing with only 14 characters?

You must be signed in to comment.

What's this?

commandlinefu.com is the place to record those command-line gems that you return to again and again. That way others can gain from your CLI wisdom and you from theirs too. All commands can be commented on, discussed and voted up or down.

Share Your Commands



Stay in the loop…

Follow the Tweets.

Every new command is wrapped in a tweet and posted to Twitter. Following the stream is a great way of staying abreast of the latest commands. For the more discerning, there are Twitter accounts for commands that get a minimum of 3 and 10 votes - that way only the great commands get tweeted.

» http://twitter.com/commandlinefu
» http://twitter.com/commandlinefu3
» http://twitter.com/commandlinefu10

Subscribe to the feeds.

Use your favourite RSS aggregator to stay in touch with the latest commands. There are feeds mirroring the 3 Twitter streams as well as for virtually every other subset (users, tags, functions,…):

Subscribe to the feed for: