Permalink
Browse files

Four4Sample - redefine factorial to be invalid for 1 & 2

  • Loading branch information...
bobbymcr committed Mar 11, 2018
1 parent 8acf697 commit 911d0cb55d202122ca6b3d200e62705d0ff16649
Showing with 5 additions and 3 deletions.
  1. +4 −2 projects/Four4Sample/Four4.Test/EvalTest.cs
  2. +1 −1 projects/Four4Sample/Four4/Number.cs
@@ -87,14 +87,16 @@ public void Division(string input, string result)
[InlineData("4 !", "24")]
[InlineData("4 .4 / !", "3628800")]
[InlineData("4 4 / 4 + !", "120")]
[InlineData("4 4 / ! ! !", "1")]
[InlineData("4 4 - ! ! !", "1")]
[InlineData("4 4 / ! ! !", "NaN")]
[InlineData("4 4 - ! ! !", "NaN")]
[InlineData(".4 !", "NaN")]
[InlineData("4 4 - 4 - !", "NaN")]
[InlineData("4 4 - 4 - ! !", "NaN")]
[InlineData("!", "NaN")]
[InlineData("4 4 !", "NaN")]
[InlineData("4 ! !", "NaN")]
[InlineData("4 4 / !", "NaN")]
[InlineData("4 4 + 4 / !", "NaN")]
public void Factorial(string input, string result)
{
Test(input, result);
@@ -84,7 +84,7 @@ public static Number Parse(string s)
public Number Factorial()
{
if ((this.num < 0) || (this.denom != 1))
if ((this.num < 0) || (this.denom != 1) || (this.num == 1) || (this.num == 2))
{
return NaN;
}

0 comments on commit 911d0cb

Please sign in to comment.