Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6530777
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T09:47:48+00:00 2026-05-25T09:47:48+00:00

I am trying to write a program that will take the users input value

  • 0

I am trying to write a program that will take the users input value and asks whether they want to calculate the value of the numbers 1 to n or the factorial of n!
This is what I have so far

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Project_2_Part_B
{
    class Program
    {
        static void Main(string[] args)
        {
            var Fkeylow = "f";
            var FkeyCap = "F";
            var Skeylow="s";
            var SkeyCap="S";
            int n = 0;
            long factorial = n;

            Console.WriteLine("Input a value n");
            n = Convert.ToInt32(Console.ReadLine());

            Console.WriteLine("Do you want to calculate factorial or sum");
            Console.WriteLine("Enter F or S");

            var A = Console.ReadLine();

            if (A == Fkeylow)
                Console.WriteLine();

            if (A == FkeyCap)
                Console.WriteLine();

            var B=Console.ReadLine();

            if (B == Skeylow)
                Console.WriteLine();

            if (B == SkeyCap)
                Console.WriteLine();

            Console.WriteLine("Press any key to close...");
            Console.ReadLine();
        }
    }
}

My issue is with the syntax of the calculation to make the code execute the n*(n-1) while n>1.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-25T09:47:49+00:00Added an answer on May 25, 2026 at 9:47 am
    static void Main(string[] args)
    {
        Console.WriteLine("Input a value n");
        string number = Console.ReadLine(); // Read number
        int n = Convert.ToInt32(number); // Converting to int
    
        Console.WriteLine("Do you want to calculate factorial or sum? ");
        Console.WriteLine("Enter F or S. ");
        string choose = Console.ReadLine(); // F or S
    
        int result = -1; // To view later
    
        if (choose == "f" || choose == "F")
        {
            result = 1;
            for (int i = n; i >= 1; i--) // Loop for calculating factorial
                result *= i;
        }
        else if (choose == "s" || choose == "S")
        {
            result = 0;
            for (int i = n; i >= 1; i--) // Loop for calculating sum
                result += i;
        }
    
        Console.WriteLine(result); // Printing answer
    
        Console.WriteLine("Press any key to close...");
        Console.ReadLine();
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying to write a fragment program that will take a texture and
I'm trying to write my first semi advanced bash script that will take input
I am trying to write a program that will accept user input which will
Hey there. I'm trying to write a small program that will read the four
I'm trying to write a simple program that will receive a string of max
I am trying to write a java program that will automatically download and name
I'm trying to write a piece of code that will do the following: Take
I'm trying to write a program that will run a program on a remote
I'm trying to write a CGI program that will output a PNG image to
I am trying to write a program that will read the existing records of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.