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

Programming Exercises

Create a PHP script to compute the sum of the first n natural numbers without using loops.

Medium

Problem Statement

Create a PHP script to compute the sum of the first n natural numbers without using loops.

Sample Input

10

Sample Output

55

Limits

Time: 2s · Memory: 256 MB

Code Editor
00:00
<?php function sumNatural($n) { // Your code here } ?>
Log in or sign up to run or submit your code.Log inSign up
Input
10
Expected Output
55