Sunday, October 5, 2025
Latest:
  • German Pronouns with Nominative, Accusative, and Dative cases
  • German articles for the nominative, accusative, and dative cases
  • Der kleine Vogel und die Sonne
  • German alphabet pronunciation
  • Command design pattern
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, 2023 code, 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

Sum of Beauty of All Substrings

May 28, 2023 beroza

ERROR: Permission to repository.git denied to username. fatal: The remote end hung up unexpectedly

August 31, 2019 beroza

Maximum Score After Splitting a String

January 10, 2023 beroza

How to horizontally center an element using CSS?

January 25, 2021 beroza

German language grammatical rules

October 21, 2024 beroza

WordPress security plugins

November 14, 2019 beroza

MongoDB useful cheat sheet

November 14, 2021 beroza

Amazon SNS and SQS related important links

May 11, 2022 beroza

What is a nested class? Builder pattern with nested class

October 3, 2024 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

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.