Saturday, November 15, 2025
Latest:
  • What are the main differences between ApplicationContext and BeanFactory?
  • German B1 Word list
  • How does Lazy annotation work in Spring?
  • How Spring framework resolves circular dependencies?
  • German Pronouns with Nominative, Accusative, and Dative cases
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

How to compile TypeScript in command line?

April 26, 2022 beroza

How to uninstall or remove apache2 using command line?

July 15, 2021 beroza

Write a program to decrypt string from alphabet to integer mapping

June 8, 2022 beroza

REST API best practices

February 23, 2022 beroza

Group array of strings by first letter

February 12, 2022 beroza

How to read the logs inside a pod?

January 19, 2024 beroza

Mergesort algorithm

December 17, 2022 beroza

List.of() vs Collections.emptyList() which one is better?

July 24, 2020 beroza

How to get radio button value using JavaScript?

July 16, 2019 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.