Answers for "sum of numbers from 0 to n python"

2

program to find sum till n natural numbers in python

#sum of natural number till n.
n=int(input('no. :'))
gross=0
no=0
while no < n:
    no+=1
    gross+=no
    print('no.', no ,'sum of n', gross)
print('no.',n,'total',gross)
Posted by: Guest on December-11-2021
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 "sum of numbers from 0 to n python"

Python Answers by Framework

Browse Popular Code Answers by Language