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

Programming Exercises

Write a function to calculate the sum of all prime numbers up to a given number.

Medium

Problem Statement

Write a function to calculate the sum of all prime numbers up to a given number.

Sample Input

n = 10

Sample Output

17

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
// Sum all prime numbers up to n function sumPrimes(n) { } console.log(sumPrimes(10));
Log in or sign up to run or submit your code.Log inSign up
Input
n = 10
Expected Output
17