remove redundant code
This commit is contained in:
1 file changed
+7
-11
@@ -46,17 +46,13 @@ public class Factorial {
|
|||||||
|
|
||||||
int number = readPositiveInt();
|
int number = readPositiveInt();
|
||||||
|
|
||||||
if (number == 0) {
|
int product = 1;
|
||||||
System.out.println("The factorial of 0 is 1.");
|
for (int i = 2; i <= number; i++) {
|
||||||
} else {
|
product *= i;
|
||||||
int product = 1;
|
|
||||||
for (int i = 2; i <= number; i++) {
|
|
||||||
product *= i;
|
|
||||||
}
|
|
||||||
System.out.println("The factorial of "
|
|
||||||
+ number + " is "
|
|
||||||
+ product + "."
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
System.out.println("The factorial of "
|
||||||
|
+ number + " is "
|
||||||
|
+ product + "."
|
||||||
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user