+ 1

Can u Someone help me figure the out?

The program you are given takes a positive number N as input. Complete the program to calculate the sum of all numbers from 1 to N inclusive. Sample Input 4 Sample Output 10

5th Jan 2021, 9:54 PM
Swiff _Vastolorde
Swiff _Vastolorde - avatar
5 Respuestas
+ 3
n = int(input()) sum = 0 for num in range(1,n+1): sum += num print(sum)
5th Jan 2021, 10:09 PM
🔥EACY🔥
🔥EACY🔥 - avatar
+ 1
try this Recursive method! namespace SoloLearn { class Program { static void Main(string[] args) { int number = 4; Console.WriteLine(Sum(number)); } static int Sum(int num) { if(num == 1) { return 1; } else{ return num += Sum(num -1); } } } }
6th Jan 2021, 10:35 PM
Monica Martinez
Monica Martinez - avatar
0
Swiff _Vastolorde, show your attempt please.
5th Jan 2021, 9:55 PM
Dino Wun (Use the search bar plz!)
Dino Wun (Use the search bar plz!) - avatar
0
Hey 🔥EACY🔥 do you know the c#?
5th Jan 2021, 10:37 PM
Swiff _Vastolorde
Swiff _Vastolorde - avatar
0
Dino Wun (Use the search bar plz!) Look below it's in c#. int N =; Convert.ToInt32(Console.ReadLine()); int sum = 0; //your code goes here for(sum = 0; N > 10; N+=1) Console.WriteLine(sum);
5th Jan 2021, 10:39 PM
Swiff _Vastolorde
Swiff _Vastolorde - avatar