using vi for scripting
I need to write a program that takes a number and shows the result of n!
Example: 5!=1*2*3*4*5 Thank you in advance for your help. |
Hmmm, is this homework? If so, please post what you have done so far.
Also, VI is an editor, what programming language are you supposed to be writing this program in? |
I'm not sure if I should be using if or a while loop or something else
echo "Please enter a number" read num count=0 total=0 if test $count -lt $num then let count=$count+1 let total=$num*$count fi echo $total |
Quote:
Code:
#!/bin/Bash |
Also, do a google search on factorial, factorial bash or factorial programming.
|
Hi TB0ne,
the OP is asking about factorial calcs https://en.wikipedia.org/wiki/Factorial, not just any multiplication set. ;) |
Quote:
|
I'm curious what you mean about "using vi", for scripting. As mentioned, vi is just a text editor. However it is possible to write scripted input for it to edit files automatically.
None of that has much to do with shell arithmetic, however. Probably the easiest way to do a factorial (assuming integer input, of course), is with a simple c-style for loop. |
if you need help on using vi, i can help but otherwise you should put your thread on the programming forum.
|
All times are GMT -5. The time now is 11:35 PM. |