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 /662/DEPENDENCIES/second_file.sci | |
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 '662/DEPENDENCIES/second_file.sci')
-rwxr-xr-x | 662/DEPENDENCIES/second_file.sci | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/662/DEPENDENCIES/second_file.sci b/662/DEPENDENCIES/second_file.sci new file mode 100755 index 000000000..adb2a8c77 --- /dev/null +++ b/662/DEPENDENCIES/second_file.sci @@ -0,0 +1,29 @@ +//Programming Example 8.12
+//calculate Fibonacci number (F=1 for i<3, and F= F1+F2 for i>=3)
+ //Second File
+
+function[f]=Fibonacci(count)
+global f1;
+global f2;
+global first;
+
+//As in static variables the initialization takes place only once
+//but static is not available in scilab
+// hence use of global variable first is made here
+// and initialized only once..
+if(first=="true") then
+ f1=1;
+ f2=1 ;
+ first="false" ;
+end
+
+
+ if(count<3) then
+ f=1
+ else
+ f=f1+f2
+ end
+ f2=f1;
+ f1=f;
+ return f;
+endfunction
\ No newline at end of file |