Member Avatar for barthdesv

Hi
I wrote a litle code to calculate factorial, but when I compile it, it says " ';' expected " (In the " for ")
Here is my code :

/**
 * A class to calculate factorial of a number
 * 
 * @author Barth 
 * @version 10/29/10
 */
public class main
{
    public static void main (String[] args)
    {
        int f = LibrairieIO.readInt ("whrite a number : ");
        
        if (f==0 || f==1)
        {
            System.out.println (" !" + f + " = 1");
        }
        
        else
        {
            int g;
            for (int a==f; a>0; a--;)
            {
                g=g*a;
            }
            
            System.out.println (" !" = f + " = " + g);
        }
    }
}

Could someone help me please?
Thank you

Recommended Answers

All 2 Replies

Re-read that for() line. You have two unnecessary characters in it.

Member Avatar for barthdesv

Ok I found thems
Thank you ezzaral

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.