PHP | gmp_add() for adding large numbers Last Updated : 13 Apr, 2018 Comments Improve Suggest changes Like Article Like Report The gmp_add() is a built-in function in PHP which is used to add two GMP numbers (GNU Multiple Precision : For large numbers). Syntax : gmp_add ( $num1, $num2 ) Parameters: This function accepts two GMP numbers as mandatory parameters as shown in the above syntax. These can be a GMP object in PHP version 5.6 and later, or a numeric string provided that it is possible to convert the latter to a number. This function adds these two numbers and returns it. Return Value: This function returns a GMP number which is sum of the two numbers passed as parameter. Examples: Input : "123456789", "987654321" Output : 1111111110 Input : "5628179032615", "7136454221086" Output : 12764633253701 Below programs illustrate the gmp_add() function in PHP : Program 1 : php <?php $sum = gmp_add("5628179032615", "7136454221086"); echo gmp_strval($sum); ?> </div> Output: 12764633253701 Program 2: php <?php $sum = gmp_add("123456789", "987654321"); echo gmp_strval($sum); ?> Output: 1111111110 Reference: http://php.net/manual/en/function.gmp-add.php Comment More infoAdvertise with us Next Article PHP | gmp_add() for adding large numbers R RICHIK BHATTACHARJEE Follow Improve Article Tags : Misc Web Technologies PHP PHP-math Practice Tags : Misc Similar Reads PHP | gmp_fact() for large factorials The gmp_fact() is a built-in function in PHP which is used to calculate the factorial of a GMP number (GNU Multiple Precision : For large numbers). Syntax: gmp_fact ( $num ) Parameters: This function accepts a GMP number as a mandatory parameter as shown in the above syntax. It can be a GMP object i 1 min read How to Deal with Large Numbers in JavaScript ? Large numbers are the numbers that can hold huge memory and evaluation time is more than exceeds space and time to process. We can deal with large numbers in JavaScript using the data type BigInt. Advantages:It can hold numbers of large sizes.It performs arithmetic operations.Disadvantages:Consumes 3 min read PHP | Check if a number is armstrong number Given a number, we need to check whether it is an armstrong number or not in PHP. An Armstrong number is the one whose value is equal to the sum of the cubes of its digits.Examples: Input : 407 Output : Yes 407 = (4*4*4) + (0*0*0) + (7*7*7) = 64 + 0 + 343 = 407 Input : 303 Output : No Approach: For 2 min read PHP gmp_legendre() Function The gmp_legendre() function is an in-built function in PHP which computes the Legendre symbol of two GMP numbers (GNU Multiple Precision: For large numbers) $num1 and $num2 passed as parameters to the function and returns it. $num2 must be positive and odd. Syntax: gmp_legendre( $num1, $num2 ) Param 2 min read PHP | gmp_invert() for inverse modulo The gmp_invert() is a built-in function in PHP which is used to find the modular inverse of a GMP number (GNU Multiple Precision : For large numbers) under another GMP number. The modular inverse is a number x such that: a x ≡ 1 (mod b) The value of x should be in {0, 1, 2, ⦠b-1}, i.e., in th 3 min read Like