Custom Search

Saturday 21 April 2012

Write a Linux shell script that evaluates the following series 1+1/1+1/2+1/3+...+1/n, Unix program to evaluates the series


Write a Linux shell script that evaluates the following series 1+1/1+1/2+1/3+...+1/n, Unix program to evaluates the series


Program
clear
echo"Enter number upto which series to be printed"
read n
sum=1
for((i=1;i<=n;i++))
do
 sum='echo$sum +1\$i|bc-1'
done
echo$ sum


Output:
Enter number upto which series to be printed:2
2.5
<<< Previous  ||  Current  ||  Next >>>  

No comments:

Post a Comment

Laptops