Computer Science Canada Factorial Calculator |
Author: | josh [ Sun Oct 03, 2004 12:24 pm ] | ||
Post subject: | Factorial Calculator | ||
I have to make a program that accepts a number between 1 and 30 from the user and then calcualte the factorial of the number. The code I have so far when I input the number 4 it says the factorial is 0 when it should be 24. here is my code:
Can someone tell me what I am doing wrong. I know it has something to do with my equation inside of the for loop. thanx |
Author: | Tony [ Sun Oct 03, 2004 1:24 pm ] | ||||||
Post subject: | |||||||
i decreases down to 1, at which point it is
1 * 0 is clearly 0 ![]() what you want is
|
Author: | josh [ Sun Oct 03, 2004 2:03 pm ] |
Post subject: | |
Thanx for the help. I should have realized that. ![]() |
Author: | wtd [ Sun Oct 03, 2004 2:11 pm ] | ||
Post subject: | |||
The recursive solution is simpler by far. ![]()
|
Author: | josh [ Sun Oct 03, 2004 2:28 pm ] |
Post subject: | |
I am in grade 10 compsci adn we havent learnt functions yet. I know about them from Java but my teach wanted us to use loops within loops. |
Author: | apomb [ Mon Oct 04, 2004 9:16 am ] |
Post subject: | |
just a question rysticlight, you learned java before Turing!? why?? i started turing in gr 10 programming then java in gr 11 ... i found that the ppl that didnt have the background in turing didint do as well, is/was this the case in your class? |
Author: | josh [ Mon Oct 04, 2004 1:08 pm ] |
Post subject: | |
I took a two week course over the summer where you learn game programming in Java, made my own asteroids game which I am tryign to figure out how to compile so I can post here. I use eclipse. there are difingntly alot of ppl in my class who should not be here but since we are learning turing I thik they will be O.k. My school does turing in grade 10, VB in grade 11, and Java in grade 12 |
Author: | apomb [ Mon Oct 04, 2004 1:26 pm ] |
Post subject: | |
WOW ... thats a kinda back asswards approach, although VB is Very object oriented and has some similarities to java (note some meaning none) however, have they ever considered C++ in 12 and JAVA in 11 and turing in 10 ... (and Flash, javascript and html in Gr 12-web developing) |
Author: | Tony [ Mon Oct 04, 2004 1:43 pm ] |
Post subject: | |
vb is not object oriented... atleast not in the sence its taught ![]() and the bottom line is that schools teach whatever the teacher wants.. or rather whatever your teacher might have a remote knowledge of ![]() |
Author: | josh [ Mon Oct 04, 2004 1:57 pm ] |
Post subject: | |
no I don't think my school would ever consider C++ right now (even though they have Visual C++ ![]() and tony my skool hgas no web developing course that I know of (they do a bit of flash in comtech) |
Author: | apomb [ Mon Oct 04, 2004 5:56 pm ] |
Post subject: | |
well, i guess that just shows how noobish i can be ... i must have confused "click and drag" with object oriented... i guess. ![]() ![]() tony wrote: and the bottom line is that schools teach whatever the teacher wants.. or rather whatever your teacher might have a remote knowledge of
good point too tony, i was merely stating what was toght at my school, and wondering about methods at different schools, that is all ![]() |
Author: | wtd [ Mon Oct 04, 2004 5:58 pm ] |
Post subject: | |
For what it's worth, VB.NET is very object-oriented. That doesn't make it good, but it's more important to know why a language sucks than just that it does. |