Melanie Ruth

Greenhorn

Posts: 11

Melanie Ruth

Greenhorn

Posts: 11

Melanie Ruth

Greenhorn

Posts: 11

posted 1 year ago

I added the code and did a number of different tries here are the results:

Enter The Number: 10

The Factorial of 10 is 1

Enter The Number: 1

The Factorial of 1 is 1

Enter The Number: 0

The Factorial of 0 is 1

Enter The Number: 6

The Factorial of 6 is 1

Enter The Number: 8

The Factorial of 8 is 1

Enter The Number: 4

The Factorial of 4 is 1

Everything turned out to be 1...

Enter The Number: 10

The Factorial of 10 is 1

Enter The Number: 1

The Factorial of 1 is 1

Enter The Number: 0

The Factorial of 0 is 1

Enter The Number: 6

The Factorial of 6 is 1

Enter The Number: 8

The Factorial of 8 is 1

Enter The Number: 4

The Factorial of 4 is 1

Everything turned out to be 1...

Campbell Ritchie

Marshal

Posts: 56599

172

posted 1 year ago

You seem to have a

Your actual formula looks correct, but you should as shown in the old stye guide, use the one‑line format.

`long`somewhere and claim to return an`int`from that method. Stick to one type, probably`long`, which will go about as far as 21! whereas an`int`runs out of range after 12! If you need any more that that, use BigInteger. You seem to me mixing types, so I am surprised that code will compile. You probably have an old version of the .class file, so get rid of the compiler errors and run the code again.Your actual formula looks correct, but you should as shown in the old stye guide, use the one‑line format.

Melanie Ruth

Greenhorn

Posts: 11