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

Programming Exercises

Create a custom function in R to calculate the nth power of a number.

Medium

Problem Statement

Create a custom function in R to calculate the nth power of a number.

Sample Input

Base: 2
Exponent: 4

Sample Output

Result: 16

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
# Predefined structure power <- function(base, exponent) { # Your logic here } result <- power(2, 4) print(paste("Result:", result))
Log in or sign up to run or submit your code.Log inSign up
Input
Base: 2
Exponent: 4
Expected Output
Result: 16