Skip to content

Commit cde51d3

Browse files
committed
Merge pull request phaserjs#940 from alvinsight/dev
Added factorial and updated to pass jshint :)
2 parents cc6aa73 + 6f0a911 commit cde51d3

1 file changed

Lines changed: 26 additions & 4 deletions

File tree

src/math/Math.js

Lines changed: 26 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -829,7 +829,7 @@ Phaser.Math = {
829829
/**
830830
* A Linear Interpolation Method, mostly used by Phaser.Tween.
831831
* @method Phaser.Math#linearInterpolation
832-
* @param {number} v
832+
* @param {Array} v
833833
* @param {number} k
834834
* @return {number}
835835
*/
@@ -856,7 +856,7 @@ Phaser.Math = {
856856
/**
857857
* A Bezier Interpolation Method, mostly used by Phaser.Tween.
858858
* @method Phaser.Math#bezierInterpolation
859-
* @param {number} v
859+
* @param {Array} v
860860
* @param {number} k
861861
* @return {number}
862862
*/
@@ -877,7 +877,7 @@ Phaser.Math = {
877877
/**
878878
* A Catmull Rom Interpolation Method, mostly used by Phaser.Tween.
879879
* @method Phaser.Math#catmullRomInterpolation
880-
* @param {number} v
880+
* @param {Array} v
881881
* @param {number} k
882882
* @return {number}
883883
*/
@@ -936,6 +936,28 @@ Phaser.Math = {
936936
return this.factorial(n) / this.factorial(i) / this.factorial(n - i);
937937
},
938938

939+
/**
940+
* @method Phaser.Math#factorial
941+
* @param {number} value - the number you want to evaluate
942+
* @return {number}
943+
*/
944+
factorial : function( value ){
945+
946+
if(value === 0)
947+
{
948+
return 1;
949+
}
950+
951+
var res = value;
952+
953+
while( --value )
954+
{
955+
res *= value;
956+
}
957+
958+
return res;
959+
},
960+
939961
/**
940962
* Description.
941963
* @method Phaser.Math#catmullRom
@@ -1364,4 +1386,4 @@ Phaser.Math = {
13641386

13651387
}())
13661388

1367-
};
1389+
};

0 commit comments

Comments
 (0)