5 Replies
namespace ConsoleApp5
{
class Program
{
static void Main (string[] args)
{
Console.WriteLine("enter a Positive number ");
int num1 = int.Parse(Console.ReadLine());
} } } code so far how do i make the Factorial dont write the code just lmk how do i do that
} } } code so far how do i make the Factorial dont write the code just lmk how do i do that
is this some sort of task that you've got with instructions to do it a specific way at all?
ye i got instructions
Write a program that calculates the sum of the first n positive integers, where n is a user-entered positive integer.
For example for n = 5 the program will print 1+2+3+4+5
Have you used recursion before?
i got it thanks.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp5
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("enter a Positive number ");
int num1 = int.Parse(Console.ReadLine());
while (num1 > 0) { for (int i = num1 - 1; i > 0; i--) { num1 += i; } Console.WriteLine("Factorial = {1}\n", num1, num1); num1--; Console.ReadLine(); } } } }
while (num1 > 0) { for (int i = num1 - 1; i > 0; i--) { num1 += i; } Console.WriteLine("Factorial = {1}\n", num1, num1); num1--; Console.ReadLine(); } } } }