Loopy Thinking Comments

Comments

  • no comments? has no one finished this yet? its not that difficult...

  • @Mitchell, many people have solved it, just not many commented here. We don't want users to paste solutions or long code samples here, but you can link to your most recent submission instead by clicking on "Load Link" below the comment form.

  • Will the answer that was given run forever since the condition is less than or equal to a.?

  • Bernard, it will stop when 'i' in the for statement increments up to the same number as the 'a'.

  • have to pay already?? you have failed this community

  • int kq=1;
    for(int i=a;i>0;i=i-1){
    kq=kq*i;
    }
    return kq;

  • You can solve this with recursion.
    public static int doStuff(int a){
    if (a==0 || a==1) return 1;
    return doStuff(a-1)*a;
    }

  • I just gave 2 as the initial value of the variable i so I think my code will just jump the first useless iteration: 1*1.
    my code

  • import java.util.Scanner;
    public class Factorial {
    public static void main(String[] args){

        Scanner input = new Scanner (System.in);
    
        System.out.print("Enter a number to calculate: ");
    
    cont...
  • int b = a;
    while(a!=1)
    {
    b = b*(a-1);
    a -= 1;
    }
    return b;

  • why don't we get infinate free lessions!?!?!?this is the only good site i have found )=
    )=
    )=

  • Here's a coupon that gives you membership for $2 for the first month: LEARNCODING99
    Enter it at learneroo.com/get-membership before checking out.
    (Membership goes to regular rate afterwards, but you can cancel if you're no longer interested.)

Contact Us
Sign in or email us at [email protected]