1-Given a number, we need to find sum of its digits using recursion. Examples: Input : 12345 Output : 15 Input : 45632 Output :20 2-Given a number n, find sum of first n natural numbers. To calculate...

Java 2
1-Given a number, we need to find sum of its digits using recursion.<br>Examples:<br>Input : 12345<br>Output : 15<br>Input : 45632<br>Output :20<br>2-Given a number n, find sum of first n natural numbers. To calculate the sum, we<br>will use a recursive function recur_sum().<br>Program to find sum of firstn natural numbers<br>6+5+4+3+2+1 = 21<br>Examples :<br>Input : 3<br>Output : 6<br>Explanation : 1 + 2 + 3 = 6<br>Input : 5<br>Output : 15<br>Explanation : 1 + 2 + 3 + 4 + 5 = 15<br>

Extracted text: 1-Given a number, we need to find sum of its digits using recursion. Examples: Input : 12345 Output : 15 Input : 45632 Output :20 2-Given a number n, find sum of first n natural numbers. To calculate the sum, we will use a recursive function recur_sum(). Program to find sum of firstn natural numbers 6+5+4+3+2+1 = 21 Examples : Input : 3 Output : 6 Explanation : 1 + 2 + 3 = 6 Input : 5 Output : 15 Explanation : 1 + 2 + 3 + 4 + 5 = 15

Jun 06, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here