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

Programming Exercises

Write an R program to calculate the Fibonacci sequence up to the 10th term using a loop.

Medium

Problem Statement

Write an R program to calculate the Fibonacci sequence up to the 10th term using a loop.

Sample Input

None

Sample Output

 [1]  0  1  1  2  3  5  8 13 21 34

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
# Predefined structure fibonacci <- function(n) { # Your logic here } print(fibonacci(10))
Log in or sign up to run or submit your code.Log inSign up
Input
None
Expected Output
 [1]  0  1  1  2  3  5  8 13 21 34