Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Generate the Fibonacci sequence up to n terms

Easy

Problem Statement

Generate the Fibonacci sequence up to n terms

Sample Input

5

Sample Output

0 1 1 2 3 

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
public class Main { public static int[] fibonacci() { int n = 5; // Your code here return new int[0]; } }
Log in or sign up to run or submit your code.Log inSign up
Input
5
Expected Output
0 1 1 2 3