Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Factorial Calculator, formula help :?
Author Message
scorpia95

Posted: Sun Feb 01, 2015 11:00 pm   Post subject: Factorial Calculator, formula help :?

There is no textbox to input a number, its supposed to start from 1 when you click "Next"

When I click "Next" on my calculator, it's supposed to say 1, and the factorial of 1. Then if I click the button again, it's supposed to say 2 and the factorial of 2. If I click next again its supposed to say 3 and the factorial of 3 and so on...

I don't understand how Its supposed to switch over to the next number when I click the button "Next".

Insectoid

Posted: Mon Feb 02, 2015 12:13 am   Post subject: RE:Factorial Calculator, formula help :?

You can use a textbox that is does not accept input and is not editable by the user. The 'next' button should edit the text in that box, using the built-in textbox properties.
scorpia95

Posted: Mon Feb 02, 2015 12:32 am   Post subject: Re: RE:Factorial Calculator, formula help :?

Insectoid @ Mon Feb 02, 2015 12:13 am wrote:
You can use a textbox that is does not accept input and is not editable by the user. The 'next' button should edit the text in that box, using the built-in textbox properties.

Cant, we were told that both the number and the factorial box are labels

Im supposed to be making something like this

http://oi58.tinypic.com/2dpggj.jpg
Nathan4102

Posted: Mon Feb 02, 2015 7:55 am   Post subject: RE:Factorial Calculator, formula help :?

In the buttonPressed event of your "Next" button, you could increment a variable by 1, set the number label to your variable, and set the factorial box to the factorial of your variable.
scorpia95

Posted: Mon Feb 02, 2015 12:12 pm   Post subject: Re: Factorial Calculator, formula help :?

ty, i figured it out. Now Im stuck at my formula

Formula:
N! = (1^2)*(2^2)*(3^2)...*(N^2)

Im doing this

x = x + 1
N.Text = x
For i = 1 To x
y = i^2 <-- my "i" isn't squaring all the values from 1 to x, its just squaring "i" at the current "x"
NFact.Text = CStr(y)
Next
Insectoid

Posted: Mon Feb 02, 2015 12:25 pm   Post subject: RE:Factorial Calculator, formula help :?

Your first problem is that your formula is wrong. Factorials are defined as N! = 1*2*3*4....*n, which is a lot simpler than what you came up with.

Because you only have to compute the 'next' factorial and not a random one, this is really easy. You won't need any loops. You start at 1. when you click 'next' you want to calculate fac(2), which is 1*2. Clicking 'next' again, you want fac(3), which is 1*2*3. But you don't need to calculate all that, because you already calculated 1*2 in the previous step. Find a way to use this to your advantage.

EDIT: I see now that you're required to use the more complicated formula. Fortunately, that doesn't matter and the advice I gave you will work the same way.
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 6 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: