As you may know, the famous <a href="https://helloacm.com/teaching-kids-programming-sum-of-distinct-positive-factorial-numbers-via-depth-first-search-algorithm/" title="Teaching Kids Programming – Sum of Distinct Positive Factorial Numbers via Depth First Search Algorithm">factorial</a> can be done in Recursion via: ``` f(n) = n * f(n-1) where f(0) = f(1) = 1 ``` <a href="https://helloacm.com/bash-function-to-install-docker/" title="BASH Function to Install Docker">BASH</a> supports function declaration and recursion - just like other modern programming language. See below the Recursive function to compute the factorial values. ``` #!/bin/bash function f() { local n=$1 if [[ $n -eq 0 ]]; then echo 1 else echo $((n*$(f $n-1))) fi } for i in {1..10}; do echo "$i!=$(f $i)" done ``` This BASH script prints the first 10 factorial numbers: ``` 1!=1 2!=2 3!=6 4!=24 5!=120 6!=720 7!=5040 8!=40320 9!=362880 10!=3628800 ``` We use "local" to keep the variables at scope of function, and we can use $() to call a function recursively. See also: <a href="https://helloacm.com/teaching-kids-programming-recursion-in-five-minutes/" title="Teaching Kids Programming – Recursion in Five Minutes">Teaching Kids Programming – Recursion in Five Minutes</a> Reposted to [Blog](https://helloacm.com/recursive-factorial-function-in-bash-programming/) ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ Thank you for reading ^^^^^^^^^^^^^^^ --------------- ## NEW! [Following my Trail (Upvote or/and Downvote)](https://steemit.com/witness-category/@justyy/following-my-trail-upvote-or-and-downvote-by-authorizing-posting-key-to-me) Follow me for topics of *Algorithms, Blockchain and Cloud.* I am @justyy - a Steem Witness [https://steemyy.com](https://steemyy.com) #### My contributions - [Video Downloader](https://weibomiaopai.com/download-video-parser.php) - [Steem Blockchain Tools](https://steemyy.com) - [Free Cryptos API](https://steemit.com/witness-category/@justyy/serverless-api-to-query-the-cryptos-and-fiat) - [VPS Database](https://anothervps.com/vps-database/) - [Computing Technology Blog](https://helloacm.com) - [A few useless tools](https://helloacm.com/tools/) - [And some other online software/tools](https://steakovercooked.com/Software.Home) - [Merge Files/Videos](https://slowapi.com/merge-videos/) - [LOGO Turtle Programming Chrome Extension](https://chrome.google.com/webstore/detail/logo-turtle-graphics/dcoeaobaokbccdcnadncifmconllpihp) - [Teaching Kids Programming - Youtube Channel](https://www.youtube.com/channel/UCK2ugmUOoYne1qQfSAph4nQ?view_as=subscriber) and [All Contents](https://github.com/DoctorLai/Teaching-Kids-Programming/blob/main/README.md) #### Delegation Service [Important Update of Delegation Service!](https://steemit.com/witness-category/@justyy/important-update-of-delegation-service) - Delegate 1000 to justyy: [Link](https://steemyy.com/sp-delegate-form/?delegatee=justyy&amount=1000) - Delegate 5000 to justyy: [Link](https://steemyy.com/sp-delegate-form/?delegatee=justyy&amount=5000) - Delegate 10000 to justyy: [Link](https://steemyy.com/sp-delegate-form/?delegatee=justyy&amount=10000) #### Support me If you like my work, please: - [Buy Me a Coffee](https://justyy.com/out/buymeacoffee), Thanks! - [Become my Sponsor](https://github.com/sponsors/DoctorLai), Thanks! - Voting for me: https://steemit.com/~witnesses type in **justyy** and click ***VOTE*** https://steemyy.com/images/vote-for-justyy.jpg 1. Delegate SP: https://steemyy.com/sp-delegate-form/?delegatee=justyy 2. Vote @justyy as Witness: https://steemyy.com/witness-voting/?witness=justyy&action=approve 3. Set @justyy as Proxy: https://steemyy.com/witness-voting/?witness=justyy&action=proxy Alternatively, you can vote witness or set proxy here: https://steemit.com/~witnesses -------------
post_id | 92,158,692 |
---|---|
author | justyy |
permlink | recursive-factorial-function-in-bash-programming |
category | programming |
json_metadata | {"tags":["programming","bash","sct","whalepower","blog","upmefund","palnet","zzan"],"users":["justyy"],"image":["https:\/\/steemyy.com\/images\/vote-for-justyy.jpg"],"links":["https:\/\/helloacm.com\/teaching-kids-programming-sum-of-distinct-positive-factorial-numbers-via-depth-first-search-algorithm\/","https:\/\/helloacm.com\/bash-function-to-install-docker\/","https:\/\/helloacm.com\/teaching-kids-programming-recursion-in-five-minutes\/","https:\/\/helloacm.com\/recursive-factorial-function-in-bash-programming\/","https:\/\/steemit.com\/witness-category\/@justyy\/following-my-trail-upvote-or-and-downvote-by-authorizing-posting-key-to-me","https:\/\/steemyy.com","https:\/\/weibomiaopai.com\/download-video-parser.php","https:\/\/steemit.com\/witness-category\/@justyy\/serverless-api-to-query-the-cryptos-and-fiat","https:\/\/anothervps.com\/vps-database\/","https:\/\/helloacm.com","https:\/\/helloacm.com\/tools\/","https:\/\/steakovercooked.com\/Software.Home","https:\/\/slowapi.com\/merge-videos\/","https:\/\/chrome.google.com\/webstore\/detail\/logo-turtle-graphics\/dcoeaobaokbccdcnadncifmconllpihp","https:\/\/www.youtube.com\/channel\/UCK2ugmUOoYne1qQfSAph4nQ?view_as=subscriber","https:\/\/github.com\/DoctorLai\/Teaching-Kids-Programming\/blob\/main\/README.md","https:\/\/steemit.com\/witness-category\/@justyy\/important-update-of-delegation-service","https:\/\/steemyy.com\/sp-delegate-form\/?delegatee=justyy&amount=1000","https:\/\/steemyy.com\/sp-delegate-form\/?delegatee=justyy&amount=5000","https:\/\/steemyy.com\/sp-delegate-form\/?delegatee=justyy&amount=10000","https:\/\/justyy.com\/out\/buymeacoffee","https:\/\/github.com\/sponsors\/DoctorLai","https:\/\/steemit.com\/~witnesses","https:\/\/steemyy.com\/sp-delegate-form\/?delegatee=justyy","https:\/\/steemyy.com\/witness-voting\/?witness=justyy&action=approve","https:\/\/steemyy.com\/witness-voting\/?witness=justyy&action=proxy"],"app":"steemit\/0.2","format":"markdown"} |
created | 2021-06-23 08:31:57 |
last_update | 2021-06-23 08:31:57 |
depth | 0 |
children | 3 |
net_rshares | 43,826,838,003,364 |
last_payout | 2021-06-30 08:31:57 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 10.977 SBD |
curator_payout_value | 10.799 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 3,883 |
author_reputation | 2,057,469,156,047,835 |
root_title | "Recursive Factorial Function in BASH Programming" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |
author_curate_reward | "" |
voter | weight | wgt% | rshares | pct | time |
---|---|---|---|---|---|
gerber | 0 | 426,131,881 | 2.6% | ||
ezzy | 0 | 32,853,036,194 | 2.6% | ||
exyle | 0 | 2,162,121,546 | 2.6% | ||
ace108 | 0 | 175,644,531,863 | 16% | ||
xiaohui | 0 | 4,611,162,481 | 100% | ||
ghasemkiani | 0 | 356,643,798,267 | 100% | ||
justyy | 0 | 40,388,538,086,863 | 100% | ||
jang | 0 | 240,563,024,953 | 100% | ||
happyukgo | 0 | 18,225,712,927 | 100% | ||
fleur | 0 | 34,900,810,505 | 100% | ||
mrpointp | 0 | 24,984,434,975 | 100% | ||
oldman28 | 0 | 26,249,573,049 | 60% | ||
kangnajiang | 0 | 200,935,366 | 100% | ||
kikima | 0 | 846,669,964 | 100% | ||
aafeng | 0 | 3,233,751,929 | 30% | ||
geass | 0 | 718,483,025 | 100% | ||
mrspointm | 0 | 15,102,499,882 | 100% | ||
accelerator | 0 | 12,806,842,620 | 2.6% | ||
acactus1013 | 0 | 3,317,004,932 | 100% | ||
rosatravels | 0 | 29,281,374,749 | 100% | ||
deathwing | 0 | 215,587,684 | 6.5% | ||
superbing | 0 | 4,563,402,034 | 100% | ||
dailyfortune | 0 | 3,689,768,327 | 100% | ||
dailystats | 0 | 5,902,112,936 | 100% | ||
khaleelkazi | 0 | 99,576,087 | 2.6% | ||
jianan | 0 | 49,404,698,625 | 100% | ||
cnbuddy | 0 | 948,941,741,460 | 100% | ||
daxiang | 0 | 224,341,953 | 100% | ||
anxin | 0 | 10,746,557,249 | 100% | ||
r351574nc3 | 0 | -303,466,179,584 | -100% | ||
mmmmkkkk311 | 0 | 1,150,536,849,952 | 100% | ||
moobear | 0 | 201,771,126 | 100% | ||
nealmcspadden | 0 | 1,895,393,247 | 2.6% | ||
foodielifestyle | 0 | 38,807,500,767 | 100% | ||
woolfe19861008 | 0 | 2,456,991,993 | 100% | ||
dailychina | 0 | 6,947,409,756 | 100% | ||
yuxuan | 0 | 29,026,578,293 | 100% | ||
dongfengman | 0 | 13,006,021,235 | 100% | ||
serenazz | 0 | 1,351,122,293 | 100% | ||
ayanamoon | 0 | 4,202,355 | 100% | ||
ethanlee | 0 | 5,413,071,431 | 100% | ||
ricardo306 | 0 | 187,972,218 | 15% | ||
fanso | 0 | 1,718,215,224 | 100% | ||
wonsama | 0 | 4,485,145,021 | 100% | ||
sd974201 | 0 | 1,758,865,197 | 5% | ||
lilypang22 | 0 | 1,579,207,393 | 100% | ||
abdullahj | 0 | 797,692,271 | 100% | ||
krnews | 0 | 405,227,262 | 100% | ||
baymaxos | 0 | 0 | 100% | ||
sweet-jenny8 | 0 | 6,989,093,802 | 100% | ||
atinna | 0 | 0 | 100% | ||
wbot01 | 0 | 139,961,241 | 100% | ||
sgbonus | 0 | 14,313,372,386 | 100% | ||
ffbank | 0 | 125,974,050 | 100% | ||
laiyuehta | 0 | 5,381,784,358 | 100% | ||
turtlegraphics | 0 | 2,751,595,680 | 100% | ||
dlike | 0 | 14,024,380,822 | 6% | ||
annasandy | 0 | 517,318,137 | 100% | ||
witnesstools | 0 | 8,014,893,995 | 100% | ||
doctor.strange | 0 | 144,003,418 | 100% | ||
dead.pool | 0 | 147,883,626 | 100% | ||
black.widow | 0 | 139,015,891 | 100% | ||
marvel.spiderman | 0 | 139,163,235 | 100% | ||
marvel.hulk | 0 | 139,051,255 | 100% | ||
marvel.ironman | 0 | 139,238,119 | 100% | ||
black.pan.ther | 0 | 139,422,259 | 100% | ||
ilovecoding | 0 | 7,622,362,805 | 100% | ||
virajherath | 0 | 87,378,861,250 | 100% | ||
claim7 | 0 | 138,550,198 | 100% | ||
wcasino | 0 | 167,421,020 | 100% | ||
wcasino.pay | 0 | 138,803,727 | 100% | ||
wcasino.holdem | 0 | 42,244,665 | 100% | ||
wcasino.jackpot | 0 | 12,685,696 | 100% | ||
steemfuckeos | 0 | 3,600,339,296 | 100% | ||
steemit.holdem | 0 | 49,004,815 | 100% | ||
steemit.jackpot | 0 | 12,687,430 | 100% | ||
smcard | 0 | 38,333,386 | 100% | ||
smonsmon | 0 | 37,731,887 | 100% | ||
guro | 0 | 37,995,018 | 100% | ||
shindorim | 0 | 37,657,440 | 100% | ||
yongsan | 0 | 37,884,246 | 100% | ||
incheon | 0 | 38,412,089 | 100% | ||
mapo | 0 | 37,700,208 | 100% | ||
shingil | 0 | 26,347,097 | 100% | ||
checkname | 0 | 38,033,150 | 100% | ||
starterpack | 0 | 26,273,835 | 100% | ||
gdragon | 0 | 37,922,214 | 100% | ||
sumimasen | 0 | 38,111,261 | 100% | ||
smtester | 0 | 37,737,722 | 100% | ||
showdown | 0 | 26,011,998 | 100% | ||
monstersteem | 0 | 38,035,945 | 100% | ||
freesale | 0 | 37,846,714 | 100% | ||
freefee | 0 | 37,660,309 | 100% | ||
testsama | 0 | 26,201,138 | 100% | ||
ctime | 0 | 87,720,682,587 | 5% | ||
kimch | 0 | 25,823,858 | 100% | ||
tongdak | 0 | 38,450,817 | 100% | ||
hanbok | 0 | 48,857,069 | 100% | ||
jjangjjangman | 0 | 25,713,376 | 100% | ||
superguard | 0 | 47,839,423 | 100% | ||
yawang | 0 | 25,599,987 | 100% | ||
roadmap | 0 | 25,938,023 | 100% | ||
kpay | 0 | 25,040,314 | 100% | ||
adultbaby | 0 | 37,925,389 | 100% | ||
sneack | 0 | 25,976,834 | 100% | ||
gzone | 0 | 37,804,804 | 100% | ||
ppororo | 0 | 38,108,127 | 100% | ||
lotto645 | 0 | 25,787,252 | 100% | ||
alphamonsters | 0 | 37,472,295 | 100% | ||
betamonsters | 0 | 38,183,386 | 100% | ||
girlfriends | 0 | 37,733,916 | 100% | ||
fastway | 0 | 37,250,973 | 100% | ||
smonsang | 0 | 25,600,140 | 100% | ||
technomart | 0 | 37,659,794 | 100% | ||
lastsmon | 0 | 25,863,660 | 100% | ||
postme | 0 | 37,249,014 | 100% | ||
boy666 | 0 | 148,310,709 | 100% | ||
smilezone | 0 | 36,759,099 | 100% | ||
bearbaby | 0 | 37,397,801 | 100% | ||
o0o0o | 0 | 53,186,468 | 100% | ||
thecards | 0 | 37,357,312 | 100% | ||
developments | 0 | 37,101,191 | 100% | ||
originals | 0 | 37,772,906 | 100% | ||
beanpole | 0 | 37,660,087 | 100% | ||
oilbank | 0 | 37,620,610 | 100% | ||
iliili | 0 | 37,285,994 | 100% | ||
kotlin | 0 | 37,136,669 | 100% | ||
flutters | 0 | 37,471,430 | 100% | ||
prettyguy | 0 | 37,284,822 | 100% | ||
gamemonsters | 0 | 52,887,701 | 100% | ||
blueguy | 0 | 130,201,881 | 100% | ||
sicbo | 0 | 152,973,301 | 100% | ||
yaoi | 0 | 165,434,068 | 100% | ||
farmfarm | 0 | 163,805,116 | 100% | ||
giantroc | 0 | 151,931,973 | 100% | ||
koboldminer | 0 | 151,745,627 | 100% | ||
crustaceanking | 0 | 165,113,546 | 100% | ||
waterelemental | 0 | 151,816,605 | 100% | ||
goblinsorcerer | 0 | 152,006,209 | 100% | ||
ragingimpaler | 0 | 152,534,889 | 100% | ||
animatedcorpse | 0 | 164,859,363 | 100% | ||
spiritforest | 0 | 152,200,431 | 100% | ||
serpentflame | 0 | 152,048,927 | 100% | ||
goblincaptain | 0 | 165,862,001 | 100% | ||
lyannaforest | 0 | 165,451,090 | 100% | ||
divineknight | 0 | 152,163,879 | 100% | ||
feralwarrior | 0 | 152,121,831 | 100% | ||
elementalair | 0 | 165,526,165 | 100% | ||
jestertwisted | 0 | 152,420,778 | 100% | ||
bansheescreaming | 0 | 152,122,611 | 100% | ||
skyselenia | 0 | 152,010,777 | 100% | ||
darknesslord | 0 | 152,087,899 | 100% | ||
lightangel | 0 | 152,494,966 | 100% | ||
naturalyanna | 0 | 152,312,980 | 100% | ||
astormbringer | 0 | 152,122,594 | 100% | ||
giantfrost | 0 | 165,565,691 | 100% | ||
warriorminotaur | 0 | 165,454,529 | 100% | ||
golemalric | 0 | 152,422,251 | 100% | ||
orcelemental | 0 | 164,294,803 | 100% | ||
spiritpriest | 0 | 152,200,667 | 100% | ||
lordjester | 0 | 165,531,079 | 100% | ||
magifirestorm | 0 | 151,674,905 | 100% | ||
muhan | 0 | 151,561,010 | 100% | ||
besthentai | 0 | 1,895,230,700 | 100% | ||
ebele | 0 | 121,119,776 | 21% | ||
smseller | 0 | 69,216,709 | 100% | ||
myselfandi | 0 | 416,588,261 | 100% | ||
blockcleaner | 0 | 27,569,324,153 | 100% | ||
steem.leo | 0 | 111,083,410 | 2.6% | ||
cplusplus | 0 | 7,480,616,889 | 100% | ||
leo.voter | 0 | 90,591,675 | 2.6% | ||
justsoso | 0 | 1,878,158,138 | 100% | ||
longhash | 0 | 1,697,656,310 | 100% | ||
lambox | 0 | 0 | -10% | ||
cestico | 0 | 0 | -10% | ||
vertyh | 0 | 0 | -10% | ||
steeemmonsters | 0 | 0 | 100% | ||
wongshiylng | 0 | 19,341,326 | 100% | ||
morningshlne | 0 | 0 | 100% | ||
sexybeach | 0 | 7,711,710,213 | 100% | ||
suckmydick | 0 | 3,614,581,136 | 100% | ||
chromebook | 0 | 2,168,650,601 | 100% | ||
ericandryan | 0 | 16,162,285,847 | 100% | ||
dev.supporters | 0 | 99,212,351,560 | 10% | ||
mrsilver | 0 | 0 | 100% | ||
plato2005 | 0 | 5,956,613,877 | 100% | ||
justyy222 | 0 | 3,615,158,533 | 100% | ||
sheya | 0 | 9,003,643,772 | 100% | ||
enchanter88 | 0 | 4,988,041,988 | 100% | ||
alpha-omega | 0 | 1,909,072,023 | 50% | ||
ldsn001 | 0 | 19,561,544,961 | 50% | ||
alegriatube12 | 0 | 594,628,089 | 15% | ||
blues529 | 0 | 5,003,073,832 | 100% | ||
villarrealjj | 0 | 4,746,352,831 | 100% | ||
mrpenmind | 0 | 1,751,657,866 | 100% |
hello, sir @justyy plz fix the voting bot. Every day I need to contact you to get upvote. It's already 40 minutes but my today's post gets no upvote. my post: https://steemit.com/hive-129948/@rme/php-half-dozones-string-operations-in-php
post_id | 92,170,422 |
---|---|
author | rme |
permlink | qv6ats |
category | programming |
json_metadata | {"users":["justyy"],"links":["https:\/\/steemit.com\/hive-129948\/@rme\/php-half-dozones-string-operations-in-php"],"app":"steemit\/0.2"} |
created | 2021-06-23 21:10:39 |
last_update | 2021-06-23 21:10:39 |
depth | 1 |
children | 2 |
net_rshares | 0 |
last_payout | 2021-06-30 21:10:39 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 SBD |
curator_payout_value | 0.000 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 238 |
author_reputation | 14,491,425,587,942,198 |
root_title | "Recursive Factorial Function in BASH Programming" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |
done.
post_id | 92,170,578 |
---|---|
author | justyy |
permlink | qv6bbj |
category | programming |
json_metadata | {"app":"steemit\/0.2"} |
created | 2021-06-23 21:21:21 |
last_update | 2021-06-23 21:21:21 |
depth | 2 |
children | 1 |
net_rshares | 0 |
last_payout | 2021-06-30 21:21:21 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 SBD |
curator_payout_value | 0.000 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 5 |
author_reputation | 2,057,469,156,047,835 |
root_title | "Recursive Factorial Function in BASH Programming" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |
thank you :D
post_id | 92,170,715 |
---|---|
author | rme |
permlink | qv6bwo |
category | programming |
json_metadata | {"app":"steemit\/0.2"} |
created | 2021-06-23 21:33:57 |
last_update | 2021-06-23 21:33:57 |
depth | 3 |
children | 0 |
net_rshares | 0 |
last_payout | 2021-06-30 21:33:57 |
cashout_time | 1969-12-31 23:59:59 |
total_payout_value | 0.000 SBD |
curator_payout_value | 0.000 SBD |
pending_payout_value | 0.000 SBD |
promoted | 0.000 SBD |
body_length | 12 |
author_reputation | 14,491,425,587,942,198 |
root_title | "Recursive Factorial Function in BASH Programming" |
beneficiaries | [] |
max_accepted_payout | 1,000,000.000 SBD |
percent_steem_dollars | 10,000 |