Friday, May 9, 2025
Latest:
  • Der kleine Vogel und die Sonne
  • German alphabet pronunciation
  • Command design pattern
  • German words with gender
  • When to use einen and keinen in German?
Upokary

Upokary

Quality information

  • Health
  • Life
  • Fashion
  • Food
  • Code
  • English
  • বাংলা
Technology 

Calculate the sum of numbers from 1 to n using recursion

Published: June 17, 2023code, program, programming, programming tips, recursion
(function(){
    // Calculate the sum of numbers from 1 to n using recursion.

    const getSum = (arr) => {
       if (arr.length < 1) {
          return 0;
       }

       return arr.pop() + getSum(arr);
    };
 
    const a = [1, 2, 3, 5];
    console.log(getSum(a))
})();

You May Also Like

Should we write a lot of code inside finally block?

June 22, 2023 beroza

Rules of writing clean code

November 6, 2022 beroza

Write a Program to Form Smallest Number From Two Digit Arrays

May 9, 2023 beroza

JavaScript console tips and tricks

December 25, 2018 beroza

How to set custom user-agent in Google chrome?

June 1, 2020 beroza

Useful maven command for developers

September 13, 2019 beroza

Type ‘null’ is not assignable to type ‘T’

December 1, 2021 beroza

Add new users to an Amazon EC2 Ubuntu instance and allow SSH access

July 22, 2020 beroza

JavaScript coding tips

August 27, 2021 beroza

Why Upokary?

Upokary.com is a useful application in everyday life. It provides very handy information regarding every aspect of life. Each and every tip of upokary.com is meant to make life better.

Upokary tools

  • Youtube thumbnail
  • Youtube video downloader

Useful Links

  • Handy code
  • Technology
  • People
  • Programming
  • Quote
  • Travel
  • WordPress
  • IELTS
  • Kids

Languages

  • EnglishEnglish
  • বাংলাবাংলা

Pages

  • Sitemap
  • Privacy policy
  • About us
  • Contact us

Support

For any kind of query or question please drop a message in the following email: upokary@gmail.com
Copyright © 2025 Upokary. All rights reserved.