@@ -131,7 +131,7 @@ discard block |
||
131 | 131 | * Note about precision: it uses the smaller of the two precisions (significant figures). |
132 | 132 | * |
133 | 133 | * @param $num |
134 | - * @param $precision |
|
134 | + * @param integer $precision |
|
135 | 135 | * @return DecimalInterface|NumberInterface |
136 | 136 | */ |
137 | 137 | public function divide($num, $precision = null) |
@@ -544,6 +544,9 @@ discard block |
||
544 | 544 | |
545 | 545 | } |
546 | 546 | |
547 | + /** |
|
548 | + * @param ImmutableNumber $num |
|
549 | + */ |
|
547 | 550 | public function getGreatestCommonDivisor($num) |
548 | 551 | { |
549 | 552 | /** @var ImmutableNumber $num */ |
@@ -938,6 +941,10 @@ discard block |
||
938 | 941 | return strpos($this->value, '.'); |
939 | 942 | } |
940 | 943 | |
944 | + /** |
|
945 | + * @param integer $pos |
|
946 | + * @param integer $add |
|
947 | + */ |
|
941 | 948 | protected function reduceDecimals(array $decimalArray, $pos, $add) |
942 | 949 | { |
943 | 950 | |
@@ -987,9 +994,9 @@ discard block |
||
987 | 994 | abstract public function modulo($mod); |
988 | 995 | |
989 | 996 | /** |
990 | - * @param $mod |
|
997 | + * @param NumberInterface $mod |
|
991 | 998 | * |
992 | - * @return NumberInterface|DecimalInterface |
|
999 | + * @return NumberInterface |
|
993 | 1000 | */ |
994 | 1001 | abstract public function continuousModulo($mod); |
995 | 1002 |
@@ -2,17 +2,16 @@ |
||
2 | 2 | |
3 | 3 | namespace Samsara\Fermat\Types; |
4 | 4 | |
5 | -use Ds\Hashable; |
|
6 | -use Samsara\Exceptions\SystemError\LogicalError\IncompatibleObjectState; |
|
7 | -use Samsara\Exceptions\UsageError\IntegrityConstraint; |
|
8 | -use Samsara\Fermat\Numbers; |
|
9 | -use Samsara\Fermat\Provider\ArithmeticProvider; |
|
10 | -use Riimu\Kit\BaseConversion\BaseConverter; |
|
11 | -use Samsara\Fermat\Provider\SequenceProvider; |
|
12 | -use Samsara\Fermat\Provider\SeriesProvider; |
|
13 | -use Samsara\Fermat\Types\Base\DecimalInterface; |
|
14 | -use Samsara\Fermat\Types\Base\FractionInterface; |
|
15 | -use Samsara\Fermat\Types\Base\NumberInterface; |
|
5 | +use Ds\Hashable; |
|
6 | +use Samsara\Exceptions\SystemError\LogicalError\IncompatibleObjectState; |
|
7 | +use Samsara\Exceptions\UsageError\IntegrityConstraint; |
|
8 | +use Samsara\Fermat\Numbers; |
|
9 | +use Samsara\Fermat\Provider\ArithmeticProvider; |
|
10 | +use Riimu\Kit\BaseConversion\BaseConverter; |
|
11 | +use Samsara\Fermat\Provider\SequenceProvider; |
|
12 | +use Samsara\Fermat\Provider\SeriesProvider; |
|
13 | +use Samsara\Fermat\Types\Base\DecimalInterface; |
|
14 | +use Samsara\Fermat\Types\Base\NumberInterface; |
|
16 | 15 | use Samsara\Fermat\Values\ImmutableNumber; |
17 | 16 | |
18 | 17 | abstract class Number implements Hashable |
@@ -29,7 +29,7 @@ discard block |
||
29 | 29 | public function __construct($value, $precision = 10, $base = 10) |
30 | 30 | { |
31 | 31 | $this->base = $base; |
32 | - $this->value = (string)$value; |
|
32 | + $this->value = (string) $value; |
|
33 | 33 | |
34 | 34 | if (!is_null($precision)) { |
35 | 35 | if ($precision > 100) { |
@@ -179,7 +179,7 @@ discard block |
||
179 | 179 | $curVal = $this->getValue(); |
180 | 180 | $calcVal = Numbers::make(Numbers::IMMUTABLE, 1); |
181 | 181 | |
182 | - for ($i = 1;$i <= $curVal;$i++) { |
|
182 | + for ($i = 1; $i <= $curVal; $i++) { |
|
183 | 183 | $calcVal = $calcVal->multiply($i); |
184 | 184 | } |
185 | 185 | |
@@ -364,15 +364,15 @@ discard block |
||
364 | 364 | |
365 | 365 | $answer = SeriesProvider::maclaurinSeries( |
366 | 366 | $modulo, |
367 | - function ($n) { |
|
367 | + function($n) { |
|
368 | 368 | $negOne = Numbers::make(Numbers::IMMUTABLE, -1, 100); |
369 | 369 | |
370 | 370 | return $negOne->pow($n); |
371 | 371 | }, |
372 | - function ($n) { |
|
372 | + function($n) { |
|
373 | 373 | return SequenceProvider::nthOddNumber($n); |
374 | 374 | }, |
375 | - function ($n) { |
|
375 | + function($n) { |
|
376 | 376 | return SequenceProvider::nthOddNumber($n)->factorial(); |
377 | 377 | }, |
378 | 378 | 0, |
@@ -406,13 +406,13 @@ discard block |
||
406 | 406 | |
407 | 407 | $answer = SeriesProvider::maclaurinSeries( |
408 | 408 | $modulo, |
409 | - function ($n) { |
|
409 | + function($n) { |
|
410 | 410 | return SequenceProvider::nthPowerNegativeOne($n); |
411 | 411 | }, |
412 | - function ($n) { |
|
412 | + function($n) { |
|
413 | 413 | return SequenceProvider::nthEvenNumber($n); |
414 | 414 | }, |
415 | - function ($n) { |
|
415 | + function($n) { |
|
416 | 416 | return SequenceProvider::nthEvenNumber($n)->factorial(); |
417 | 417 | }, |
418 | 418 | 0, |
@@ -497,20 +497,20 @@ discard block |
||
497 | 497 | } else { |
498 | 498 | $answer = SeriesProvider::maclaurinSeries( |
499 | 499 | $modulo, |
500 | - function ($n) { |
|
500 | + function($n) { |
|
501 | 501 | $nthOddNumber = SequenceProvider::nthOddNumber($n); |
502 | 502 | |
503 | 503 | return SequenceProvider::nthEulerZigzag($nthOddNumber); |
504 | 504 | }, |
505 | - function ($n) { |
|
505 | + function($n) { |
|
506 | 506 | |
507 | 507 | return SequenceProvider::nthOddNumber($n); |
508 | 508 | }, |
509 | - function ($n) { |
|
509 | + function($n) { |
|
510 | 510 | return SequenceProvider::nthOddNumber($n)->factorial(); |
511 | 511 | }, |
512 | 512 | 0, |
513 | - $precision + 1 |
|
513 | + $precision+1 |
|
514 | 514 | ); |
515 | 515 | } |
516 | 516 | |
@@ -730,7 +730,7 @@ discard block |
||
730 | 730 | |
731 | 731 | $rounded = $whole.'.'; |
732 | 732 | |
733 | - for ($i = 0;$i < $decimals;$i++) { |
|
733 | + for ($i = 0; $i < $decimals; $i++) { |
|
734 | 734 | $rounded .= $fractionalArr[$i]; |
735 | 735 | } |
736 | 736 |
@@ -21,6 +21,10 @@ |
||
21 | 21 | |
22 | 22 | protected $symbol; |
23 | 23 | |
24 | + /** |
|
25 | + * @param integer $symbol |
|
26 | + * @param integer $precision |
|
27 | + */ |
|
24 | 28 | public function __construct($value, $symbol = Currency::DOLLAR, $precision = null, $base = 10) |
25 | 29 | { |
26 | 30 | $this->symbol = $symbol; |
@@ -11,53 +11,53 @@ |
||
11 | 11 | { |
12 | 12 | |
13 | 13 | const EULER_ZIGZAG = [ |
14 | - '1', // 0 |
|
15 | - '1', // 1 |
|
16 | - '1', // 2 |
|
17 | - '2', // 3 |
|
18 | - '5', // 4 |
|
19 | - '16', // 5 |
|
20 | - '61', // 6 |
|
21 | - '272', // 7 |
|
22 | - '1385', // 8 |
|
23 | - '7936', // 9 |
|
24 | - '50521', // 10 |
|
25 | - '353792', // 11 |
|
26 | - '2702765', // 12 |
|
27 | - '22368256', // 13 |
|
28 | - '199360981', // 14 |
|
29 | - '1903757312', // 15 |
|
30 | - '19391512145', // 16 |
|
31 | - '209865342976', // 17 |
|
32 | - '2404879675441', // 18 |
|
33 | - '29088885112832', // 19 |
|
34 | - '370371188237525', // 20 |
|
35 | - '4951498053124096', // 21 |
|
36 | - '69348874393137901', // 22 |
|
37 | - '1015423886506852352', // 23 |
|
38 | - '15514534163557086905', // 24 |
|
39 | - '246921480190207983616', // 25 |
|
40 | - '4087072509293123892361', // 26 |
|
41 | - '70251601603943959887872', // 27 |
|
42 | - '1252259641403629865468285', // 28 |
|
43 | - '23119184187809597841473536', // 29 |
|
44 | - '441543893249023104553682821', // 30 |
|
45 | - '8713962757125169296170811392', // 31 |
|
46 | - '177519391579539289436664789665', // 32 |
|
47 | - '3729407703720529571097509625856', // 33 |
|
48 | - '80723299235887898062168247453281', // 34 |
|
49 | - '1798651693450888780071750349094912', // 35 |
|
50 | - '41222060339517702122347079671259045', // 36 |
|
51 | - '970982810785059112379399707952152576', // 37 |
|
52 | - '23489580527043108252017828576198947741', // 38 |
|
53 | - '583203324917310043943191641625494290432', // 39 |
|
54 | - '14851150718114980017877156781405826684425', // 40 |
|
55 | - '387635983772083031828014624002175135645696', // 41 |
|
56 | - '10364622733519612119397957304745185976310201', // 42 |
|
57 | - '283727921907431909304183316295787837183229952', // 43 |
|
58 | - '7947579422597592703608040510088070619519273805', // 44 |
|
14 | + '1', // 0 |
|
15 | + '1', // 1 |
|
16 | + '1', // 2 |
|
17 | + '2', // 3 |
|
18 | + '5', // 4 |
|
19 | + '16', // 5 |
|
20 | + '61', // 6 |
|
21 | + '272', // 7 |
|
22 | + '1385', // 8 |
|
23 | + '7936', // 9 |
|
24 | + '50521', // 10 |
|
25 | + '353792', // 11 |
|
26 | + '2702765', // 12 |
|
27 | + '22368256', // 13 |
|
28 | + '199360981', // 14 |
|
29 | + '1903757312', // 15 |
|
30 | + '19391512145', // 16 |
|
31 | + '209865342976', // 17 |
|
32 | + '2404879675441', // 18 |
|
33 | + '29088885112832', // 19 |
|
34 | + '370371188237525', // 20 |
|
35 | + '4951498053124096', // 21 |
|
36 | + '69348874393137901', // 22 |
|
37 | + '1015423886506852352', // 23 |
|
38 | + '15514534163557086905', // 24 |
|
39 | + '246921480190207983616', // 25 |
|
40 | + '4087072509293123892361', // 26 |
|
41 | + '70251601603943959887872', // 27 |
|
42 | + '1252259641403629865468285', // 28 |
|
43 | + '23119184187809597841473536', // 29 |
|
44 | + '441543893249023104553682821', // 30 |
|
45 | + '8713962757125169296170811392', // 31 |
|
46 | + '177519391579539289436664789665', // 32 |
|
47 | + '3729407703720529571097509625856', // 33 |
|
48 | + '80723299235887898062168247453281', // 34 |
|
49 | + '1798651693450888780071750349094912', // 35 |
|
50 | + '41222060339517702122347079671259045', // 36 |
|
51 | + '970982810785059112379399707952152576', // 37 |
|
52 | + '23489580527043108252017828576198947741', // 38 |
|
53 | + '583203324917310043943191641625494290432', // 39 |
|
54 | + '14851150718114980017877156781405826684425', // 40 |
|
55 | + '387635983772083031828014624002175135645696', // 41 |
|
56 | + '10364622733519612119397957304745185976310201', // 42 |
|
57 | + '283727921907431909304183316295787837183229952', // 43 |
|
58 | + '7947579422597592703608040510088070619519273805', // 44 |
|
59 | 59 | '227681379129930886488600284336316164603920777216', // 45 |
60 | - '6667537516685544977435028474773748197524107684661',// 46 |
|
60 | + '6667537516685544977435028474773748197524107684661', // 46 |
|
61 | 61 | '199500252157859031027160499643195658166340757225472', |
62 | 62 | '6096278645568542158691685742876843153976539044435185', |
63 | 63 | '190169564657928428175235445073924928592047775873499136', |