codinasion
codinasion copied to clipboard
Write a Kotlin program to find average of numbers by recursion
Description
Write a Kotlin program to find average of numbers by recursion
Average of numbers is the sum of all numbers divided by the number of numbers. For example, the average of 1, 2, 3, 4, 5 is 3. The average of 1, 2, 3, 4, 5, 6 is 3.5.
Average of numbers can be calculated by recursion. The average of numbers is the sum of the first number and the average of the rest of the numbers. The average of the rest of the numbers is the sum of the second number and the average of the rest of the numbers. The average of the rest of the numbers is the sum of the third number and the average of the rest of the numbers. And so on.
Input : 1 2 3 4 5
Output : 3
How to contribute
- Save the solution in
program/FindAverageOfNumbersByRecursion.kt
file - Add
FindAverageOfNumbersByRecursion.kt
file infind-average-of-numbers-by-recursion
folder
!assign