- Calculate the fibonacci series by passing an argument through the calling statement.
Answers
Answered by
3
Answer:
class GFG {
// Function to print N Fibonacci Number
static void Fibonacci(int N)
{
int num1 = 0, num2 = 1;
int counter = 0;
// Iterate till counter is N
while (counter < N) {
// Print the number
System.out.print(num1 + " ");
// Swap
int num3 = num2 + num1;
num1 = num2;
num2 = num3;
counter = counter + 1;
}
}
// Driver Code
public static void main(String args[])
{
// Given Number N
int N = 10;
// Function Call
Fibonacci(N);
}
}
Similar questions
Political Science,
2 months ago
Math,
2 months ago
Science,
2 months ago
India Languages,
4 months ago
Hindi,
10 months ago
Math,
10 months ago
Math,
10 months ago