Skip to content

Computer-Scientist-01/FluxNet

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

/*

  • Name: Suraj Sanjay yadav
  • Enrollment No: M11131253065
  • Subject: 12th CS (NIOS)
  • Program: Fibonacci Sequence Generator
  • Input data: An integer 'n' (here n = 7) representing the position in the Fibonacci sequence.
  • Output data: The 'n'th Fibonacci number. For n = 7, output is 13. */

#include // Include the standard input/output stream library so we can print to the screen using namespace std; // Use the standard namespace to avoid typing 'std::' before 'cout'

// Function to calculate the nth Fibonacci number using recursion int fib(int n) { // Base case: if n is 0 or 1, the Fibonacci number is n itself if (n <= 1) return n; // Return the value of n

// Recursive step: Fibonacci number is the sum of the two previous Fibonacci numbers
return fib(n - 1) + fib(n - 2);

}

// The main function where the program starts running int main() { int n = 7; // Define the input data: we want to find the 7th Fibonacci number

// Call the function 'fib' with 'n' and print the output to the screen
cout << fib(n);

return 0; // Return 0 to indicate the program finished successfully

}

About

Web ecosystem similar to World Wide Web.

Topics

Resources

License

Stars

Watchers

Forks

Contributors

Languages