+

PHP Gmp_div_r () function

The gmp_div_r() function is a built-in PHP function that performs division operation between two GMP numbers (GNU Multiple Precision: for large numbers) and returns the remainder. 
Syntax:
gmp_div_r ($num1, $num2)
Parameters: This function accepts two GMP numbers, $num1 and $num2, as required parameters, as shown in the above syntax. These parameters can be GMP objects in PHP 5.6 and later, or numeric strings can be passed to a function, provided the strings can be converted to numbers.Returned value:this function returns the GMP number, which is the remainder of the division.Examples :
Input: $num1 = 146, $num2 = 12 Output: 2 Input : $num1 = "189126457831", $num2 = "12098123409" Output: 7654606696 
The programs below will illustrate the use of the gmp_div_r() function.Program 1:A program to perform division of GMP numbers when GMP numbers are passed as arguments.
// PHP program to perform division
// GMP numbers 
// generate GMP numbers using gmp_init()
$num1 = gmp_init (257); $num2 = gmp_init (17);  
// calculates the remainder when
// $num1 divides by num2 $res = gmp_div_r ( $num1 , $num2 ); // Show remainder echo $res ; ?>
Exit
2
Program 2:A program to perform division of GMP numbers when numeric strings are passed as GMP numbers as arguments.
// PHP program to perform division
// GMP numbers 
// create a GMP number using gmp_init ( ) $a = gmp_init ( " 7891267541121 " );  
// calculate the remainder when
// $a is divisible by 115789034 $res = gmp_div_r ( $a , 115789034);  
// Show remainder echo $res ; ?>
Exit
13295953
Link:http://php.net/manual/en/function.gmp-div-r.php
Get Solution for free from DataCamp guru