Function to check if the given number is factorial of some number or not.
+
Parameters
+
+
n
number to be checked.
+
+
+
+
Returns
true if number is a factorial returns true
+
+false if number is not a factorial
+
this loop is basically a reverse factorial calculation, where instead of multiplying we are dividing. We start at i = 2 since i = 1 has no impact division wise
+
if n was the sum of a factorial then it should be divided until it becomes 1
+
27 {
+
28if (n <= 0) { // factorial numbers are only ever positive Integers
+
29returnfalse;
+
30 }
+
31
+
32 /*!
+
33 * this loop is basically a reverse factorial calculation, where instead
+
34 * of multiplying we are dividing. We start at i = 2 since i = 1 has
+
35 * no impact division wise
+
36 */
+
37int i = 2;
+
38while (n % i == 0) {
+
39 n = n / i;
+
40 i++;
+
41 }
+
42
+
43 /*!
+
44 * if n was the sum of a factorial then it should be divided until it
Reduced all possibilities of a number which cannot be prime. Eg: No even number, except 2 can be a prime number, hence we will increment our loop with i+6 jumping and check for i or i+2 to be a factor of the number; if it's a factor then we will return false otherwise true after the loop terminates at the terminating condition which is (i*i<=num)
diff --git a/files.html b/files.html
index 534fb12e0..cbabb6a19 100644
--- a/files.html
+++ b/files.html
@@ -230,7 +230,7 @@ solve-a-rat-in-a-maze-c-java-pytho/" target="_blank">Rat in a Maze algorithm
Reduced all possibilities of a number which cannot be prime. Eg: No even number, except 2 can be a prime number, hence we will increment our loop with i+6 jumping and check for i or i+2 to be a factor of the number; if it's a factor then we will return false otherwise true after the loop terminates at the terminating condition which is (i*i<=num)