Generation

generate functionFri, 10 Feb 2023

Write a program to calculate the sum of first 10 natural number.

function sum(n){ if (n === 0){ return 0 } else { return n + sum(n - 1) } } sum(10)

Javascript
Generate More

Questions about programming?Chat with your personal AI assistant