76 273
Assignments Done
Successfully Done
In May 2019

Answer to Question #13947 in C# for neil john

Question #13947
Create a program that solves for the sum of all positive integers starting from 1 until the number given by the user. Use a recursive fuction to address this problem. Assume that the user will always enter a positive number.


Enter number: 100
Sum of integers from 1 to 100 is 5050.
Expert's answer
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Solves_for_the_sum_of_all_positive_integers
class Program
static void Main(string[] args)
int number;
Console.Write("Enter number:");
number = int.Parse(Console.ReadLine());
Console.Write("Sum of integers from 1 to " + number.ToString() + " is " +
static int Sum(int number) {
if (number > 0)
return number + Sum(number - 1);
return 1;

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!


No comments. Be first!

Leave a comment

Ask Your question

Privacy policy Terms and Conditions