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 8758533
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T14:34:25+00:00 2026-06-13T14:34:25+00:00

I am new to this website; in fact this is my first question. So

  • 0

I am new to this website; in fact this is my first question. So if I am asking this question in the wrong context, please inform me so I can make the adjustments.
I have a program that is created in Visual Studio 2010 to allow a user to enter in an integer from 1 to 10. That user will click a button which in turn should compute and display the integer’s factorial value in a text box. I thought everything looks correct but nothing is appearing in the text box.

The following code is what I have been using:

#pragma endregion
        private: System::Void btnFactorial_Click(System::Object^  sender, System::EventArgs^  e) 
        {
            int n;
            int nfact = 1;
            Int32::TryParse(txtNum->Text, n);
            if (n > 0)
            {
                for (int i = 1; i <= n; i++)
                    nfact *= i;
                txtResult->Text = nfact.ToString();
            }
            else
                MessageBox::Show ("Please enter a value > 0");      
        }

        private: int Factorial (int n)
        {
            if (n == 0)
                return 1;
            else
                return n * Factorial (n-1);
        }
    };
}

Can I ask for some help as to what I am doing wrong here?

  • 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-06-13T14:34:26+00:00Added an answer on June 13, 2026 at 2:34 pm

    You need to call your own function somewhere. Replace this:

    for (int i = 1; i <= n; i++)
                    nfact *= i;
    

    and write this:

    nfact = Factorial(n);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

New to PHP and MySQL, have heard amazing things about this website from Leo
I have a new version of my website that I'm ready to golive. This
I'm working on this website http://www.eluminatecreative.com/new/index.html and where it says sum'r fling I need
I've got a new website moved to my server. This website uses PHP and
I am receiving this Uncaught TypeError on a new website I am creating, but
I am planning a new website with codeigniter using wordpress. this site will contain
I am new this sharepoint development and i have task in hand to do
new to this site so sorry if this question is inappropriate, or in the
When I loaded up my new website I have some of it using MVC
First of all, the website I run is hosted and I don't have access

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.