C RUBY-ON-RAILS MYSQL ASP.NET DEVELOPMENT RUBY .NET LINUX SQL-SERVER REGEX WINDOWS ALGORITHM ECLIPSE VISUAL-STUDIO STRING SVN PERFORMANCE APACHE-FLEX UNIT-TESTING SECURITY LINQ UNIX MATH EMAIL OOP LANGUAGE-AGNOSTIC VB6 MSBUILD

# Why is the function to find factorial wrong?

By : Raja Mani
Date : September 23 2020, 04:00 AM
I wish this helpful for you In line 5, you overwrite the requested value of n with 0.
That then evaluates to zero (false), and the next two conditionals are also rendered false, so nothing prints.
code :

Share :

## i want to find the factorial of a given number using recursive function in c.what's wrong with the following program?

By : Arvind Balgo
Date : March 29 2020, 07:55 AM
wish help you to fix your issue You do not have a base condition in the fact function.
You need to check:
code :
`````` if(i == 1){
return 1;
}else{

return i * fact(i - 1);

}
``````

## What's wrong with this factorial function in clojure

By : mohammed Huner
Date : March 29 2020, 07:55 AM
When you recur here, you are actually recurring on the function definition which has one argument hence java.lang.IllegalArgumentException: Mismatched argument count to recur, expected: 1 args, got: 2 (NO_SOURCE_FILE:33).

## Why this factorial function gives wrong result?

By : Dwitty
Date : March 29 2020, 07:55 AM
code :
``````def Factorial(n):
result = 1
for i in range(1,n):
result = result * (i+1)
print(result)
``````
``````result = result * (result+1)
``````
``````result = result * (i + 1)
``````

## What is wrong with my Factorial Function logic?

By : Luc Ghesquiere
Date : March 29 2020, 07:55 AM
With these it helps Where you said var newX = x * i;, that declares a new variable. Remove var.
x * i will return the square of x because lastly i is x.
code :
``````function factorial(x) {
var newX = 1;
if(x > 0){
for(var i = 1;i <= x;i++){
newX = newX * i;
}
return newX;
} else {
return 1;
}
};
console.log(factorial(5));
console.log(factorial(4));
console.log(factorial(0));``````

## Haskell: What is wrong with factorial function

By : Annie Churdar
Date : March 29 2020, 07:55 AM
may help you . This is ghc being conservative. Your code has all possible values of "n" covered, but ghc isn't smart enough to prove that, so it warns you.
Try replacing your "n < 0" with "otherwise" and putting it at the end. This is defined as