gmp_gcdext

(PHP 4 >= 4.0.4, PHP 5, PHP 7, PHP 8)

gmp_gcdextCalculate GCD and multipliers

Beschreibung

gmp_gcdext(GMP|int|string $num1, GMP|int|string $num2): array

Calculates g, s, and t, such that a*s + b*t = g = gcd(a,b), where gcd is the greatest common divisor. Returns an array with respective elements g, s and t.

This function can be used to solve linear Diophantine equations in two variables. These are equations that allow only integer solutions and have the form: a*x + b*y = c. For more information, go to the » "Diophantine Equation" page at MathWorld

Parameter-Liste

num1

Ein GMP-Object, ein Integer oder eine numeriche Zeichenkette.

num2

Ein GMP-Object, ein Integer oder eine numeriche Zeichenkette.

Rückgabewerte

An array of GMP numbers.

Beispiele

Beispiel #1 Solving a linear Diophantine equation

<?php
// Solve the equation a*s + b*t = g
// where a = 12, b = 21, g = gcd(12, 21) = 3
$a gmp_init(12);
$b gmp_init(21);
$g gmp_gcd($a$b);
$r gmp_gcdext($a$b);

$check_gcd = (gmp_strval($g) == gmp_strval($r['g']));
$eq_res gmp_add(gmp_mul($a$r['s']), gmp_mul($b$r['t']));
$check_res = (gmp_strval($g) == gmp_strval($eq_res));

if (
$check_gcd && $check_res) {
    
$fmt "Solution: %d*%d + %d*%d = %d\n";
    
printf($fmtgmp_strval($a), gmp_strval($r['s']), gmp_strval($b),
    
gmp_strval($r['t']), gmp_strval($r['g']));
} else {
    echo 
"Error while solving the equation\n";
}

// output: Solution: 12*2 + 21*-1 = 3
?>

Hier Kannst Du einen Kommentar verfassen


Bitte gib mindestens 10 Zeichen ein.
Wird geladen... Bitte warte.
* Pflichtangabe
Es sind noch keine Kommentare vorhanden.

Was genau bedeutet "Vibe Coding"? Ein tiefgehender Blick für Entwickler

In der Welt der Softwareentwicklung gibt es unzählige Wege, wie man an ein Projekt herangeht. Manche schwören auf strikte Planung, andere auf bewährte Algorithmen und wieder andere lassen sich von etwas ganz anderem leiten: ihrem Gefühl. ...

admin

Autor : admin
Kategorie: Software & Web-Development

PHP cURL-Tutorial: Verwendung von cURL zum Durchführen von HTTP-Anfragen

cURL ist eine leistungsstarke PHP-Erweiterung, die es Ihnen ermöglicht, mit verschiedenen Servern über verschiedene Protokolle wie HTTP, HTTPS, FTP und mehr zu kommunizieren. ...

TheMax

Autor : TheMax
Kategorie: PHP-Tutorials

Midjourney Tutorial - Anleitung für Anfänger

Über Midjourney, dem Tool zur Erstellung digitaler Bilder mithilfe von künstlicher Intelligenz, gibt es ein informatives Video mit dem Titel "Midjourney Tutorial auf Deutsch - Anleitung für Anfänger" ...

Mike94

Autor : Mike94
Kategorie: KI Tutorials

Tutorial veröffentlichen

Tutorial veröffentlichen

Teile Dein Wissen mit anderen Entwicklern weltweit

Du bist Profi in deinem Bereich und möchtest dein Wissen teilen, dann melde dich jetzt an und teile es mit unserer PHP-Community

mehr erfahren

Tutorial veröffentlichen

SSN | NIN | SIN | EIN | W-2 FORMS | REAL DLs | HIGH CS FULLZ |CC FULLZ

SELL DUMPS WITH PIN, SELL CVV CC, SELL FULLZ INFO US UK EU CHINA GER CA FR… Update 2025 Sell Fullz Info SSN DOB + DL, Cvv, Dumps with Pin, PayPa ...

Geschrieben von sellergood11 am 22.05.2026 09:48:57
Forum: BRAINSTORMING PHP/SQL/HTML/JS/CSS
Hacking tools fullz shop cvv dumps bots btc crypto hacking cash out tutorials

The Best Dumps CVV SHOP 2026 Sell CCV Dumps With Pin Online Wellcome to the best dumps SHOP, here we sell dumps with pin , dumps Track 1/2 , cvv f ...

Geschrieben von sellergood11 am 22.05.2026 09:48:16
Forum: Netzwerk &amp; Internet
USA SSN DL front back with Selfie,CC & Dumps,USA SSN,Canada SIN,UK NIN

I'm good hacker and verified seller Having experience in information technology in 9 years I need best buyer and long time business Let deals and ...

Geschrieben von sellergood11 am 22.05.2026 09:47:16
Forum: Off-Topic Diskussionen
Fresh stuff of fullz|pros cc|cvv dumps[pin] ssn|sin|nin llc's insurance docs

hi customers I'm good hacker and verified seller Having experience in information technology in 9 years I need best buyer and long time business L ...

Geschrieben von sellergood11 am 22.05.2026 09:46:31
Forum: User stellen sich vor