Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Exercise1
- {
- public static int fibonacci(int n)
- {
- if((n==1)||(n==0))
- {
- return(n);
- }
- else
- {
- return(fibonacci(n-1)+fibonacci(n-2));
- }
- }
- public static string test(int n)
- {
- int i=0;
- string ans="";
- while(i<n)
- {
- ans =ans + (fibonacci(i)).ToString() +" ";
- i=i+1;
- }
- return ans;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement