Question: PHP. Please create tests as well // In mathematics, the greatest common divisor (GCD) of two or more // integers, which are not all zero,
PHP. Please create tests as well
// In mathematics, the greatest common divisor (GCD) of two or more // integers, which are not all zero, is the largest positive integer // that divides each of the integers. For example, GCD (2, 12) is 2. // Euclid's solution to finding the GCD is refuted to be the first // algorithm known to mankind. It is definitely old. // GCD (a, b) can be computed as follows: // while(b != 0): other = a a = b b = other % b // a is the GCD // // GCD (378, 378) returns 378 // GCD (378, 0) returns 378 // GCD(0, 378) returns 378 // GCD (11, 5) returns 1 // GCD (10, 5) returns 5 // GCD (25, 10) returns 5 // Precondition: a and b are >= 0 a and or b can be 0, but not both. // GCD(0, 0) is undefined. We do not have an assert for GCD(0,0). function GCD ($a, $b) { // Test this wth your own asserts return -999; } // Write your own tests here. We have about 50 total asserts
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
