Answers for "how to add up all the numbers in between 0 and that number"

1

how to add up all the numbers in between 0 and that number

function addUp(num) {
  if (num === 1) return 1;
  return num + addUp(num - 1);
}
Posted by: Guest on April-09-2020
1

how to add up all the numbers in between 0 and that number

function solution(number){
  var sum = 0;
  
  for(var i = 1;i< number; i++){
    if(i % 3 == 0 || i % 5 == 0){
      sum += i
    }
  }
  return sum;
}
Posted by: Guest on April-09-2020

Code answers related to "how to add up all the numbers in between 0 and that number"

Code answers related to "Javascript"

Browse Popular Code Answers by Language