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

Programming Exercises

Write an R program to find all the prime numbers less than a given number.

Medium

Problem Statement

Write an R program to find all the prime numbers less than a given number.

Sample Input

Number: 20

Sample Output

[1]  3  5  7 11 13 17 19

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
# Predefined structure find_primes <- function(n) { # Your logic here } print(find_primes(20))
Log in or sign up to run or submit your code.Log inSign up
Input
Number: 20
Expected Output
[1]  3  5  7 11 13 17 19