diff options
author | priyanka | 2015-06-24 15:03:17 +0530 |
---|---|---|
committer | priyanka | 2015-06-24 15:03:17 +0530 |
commit | b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b (patch) | |
tree | ab291cffc65280e58ac82470ba63fbcca7805165 /659/CH9/EX9.16 | |
download | Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.gz Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.tar.bz2 Scilab-TBC-Uploads-b1f5c3f8d6671b4331cef1dcebdf63b7a43a3a2b.zip |
initial commit / add all books
Diffstat (limited to '659/CH9/EX9.16')
-rwxr-xr-x | 659/CH9/EX9.16/topic9_16.sci | 18 | ||||
-rwxr-xr-x | 659/CH9/EX9.16/topic9_16_output.PNG | bin | 0 -> 5174 bytes |
2 files changed, 18 insertions, 0 deletions
diff --git a/659/CH9/EX9.16/topic9_16.sci b/659/CH9/EX9.16/topic9_16.sci new file mode 100755 index 000000000..080bd5be4 --- /dev/null +++ b/659/CH9/EX9.16/topic9_16.sci @@ -0,0 +1,18 @@ +// Topic 9.16 RECURSION
+// Page no. 288
+//Write a program to calculate factorial of a number using recursion
+function[fact1]=factorial1(n)
+ fact1=-1
+ if(n<0) then
+ disp("Please enter positive value[i.e. 0 or greater than 0] ");
+ return; //Quits the current function
+ end
+ if((n==0)|(n==1)) then
+ fact1=1;
+ else
+ fact1=n*factorial1(n-1); //recursive call to factorial1()
+ end
+endfunction
+n=input("Enter number:");
+//calling factorial1() function inside printf()
+printf("Factorial of %d = %d",n,factorial1(n));
\ No newline at end of file diff --git a/659/CH9/EX9.16/topic9_16_output.PNG b/659/CH9/EX9.16/topic9_16_output.PNG Binary files differnew file mode 100755 index 000000000..494791361 --- /dev/null +++ b/659/CH9/EX9.16/topic9_16_output.PNG |