+ 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
5 Respuestas
+ 3
n = int(input())
sum = 0
for num in range(1,n+1):
sum += num
print(sum)
+ 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);
}
}
}
}
0
Swiff _Vastolorde, show your attempt please.
0
Hey 🔥EACY🔥 do you know the c#?
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);