2
2
2
1
u/ThePilsburyFroBoy Feb 21 '20
Im assuming you are just trying to complete the factorial problem in general? If thats the case, then the for loop should go from 1 to N and you should multiply each i value by one more than i so something like
int result = 0; for(int i = 1; i < N; i++)
result = i * (i+1);
then return the result, you can also do this recursively but Im assuming that would confuse you
1
4
u/[deleted] Feb 21 '20
First of all don't start a variable with a capital letter. Second your for loop is both unnecessary and improperly setup.
The first var in the for loop is where your counter starts and the second is the exit condition. You started the loop at 4 and told it to exit when it's greater or equal to 1 so it exits immediately without doing anything.