WeberDev.com PHP and MySQL Code

LOG IN
BEGINNER GUIDESPHP CLASSESCODE SEARCHARTICLES SEARCHPHP FORUMSPHP MANUALPHP FUNCTIONS LISTWEB SITE TEMPLATES
Start typing to search for PHP and MySQL Code Snippets and Articles Search
Submit a code Example / Snippet Join us on FaceBook
Submit a code Example / Snippet Submit Your Code
Poker Tournaments Poker Tournaments
Poker Guide for Developers Poker Guide for Developers
Search Engine Optimization Monitor SEO Monitor
Web Site UpTime Monitor UpTime Monitor
Your Personal Examples List My Favorite Examples
Your Personal Articles List My Favorite Articles
Edit Account Info Update Your Profile
PHP Code Search
Web Development Forums
Learn MySQL Playing Trivia
PHPBB2 Templates
Web Development Resources
Web Development Content
Internet Security Software
PHPClasses
PHP Editor
PHP Jobs
Vision.To Design
Ajax Tutorials
PHP Programming Help
PHP/MySQL Programming
Webmaster Resources
Webmaster Forum
XML meta language
website builder
פרייסז - הכח לקנות עובר לידיים שלך
Texas Holdem Poker Evangelists

Go Back Add a Comment Send this example to a friend Add this Article to your personal favoritest for easy future access to your favorite Code Examples and Articles. Submit a code example Print this code example.
BACK ADD A COMMENT SEND TO A FRIEND ADD TO MY FAVORITES ADD CODE EXAMPLES PRINT
Title : BCGCD Greatest Common Denominator (Large Numbers)
Categories : PHP, BC math Click here to Update Your Picture
Sergiu FUNIERU
Date : Sep 26th 2006
Grade : 1 of 5 (graded 1 times)
Viewed : 2708
File : No file for this code example.
Images : No Images for this code example.
Search : More code by Sergiu FUNIERU
Action : Grade This Code Example
Tools : My Examples List

Submit your own code examples  Submit your own code examples 
 

The Greatest Common Denominator of two large numbers, using BCMath functions.
Please read the PHP manual for BCMath requirements.

It works even for those who cannot have GMP support in their PHP distribution,
for instance due to the web host policy.

You can see a demo here:
http://freephpcalculator.tk/
License: free to do whatever you want with the code even using it.


<?php
function bcgcd ($value1, $value2) {
   
    if (
$value1 < $value2)
   
// Swap $value1 and $value2
   
{
       
$temp = $value1;
       
$value1 = $value2;
       
$value2 = $temp;
    }

   
// We use the Euclid's algorithm
    // for finding the Greatest Common Denominator (GCD)
   
$mod = 1;
    while (
$mod != 0)
    {
       
$mod = bcmod ($value1, $value2);
       
$value1 = $value2;
       
$value2 = $mod;
    }
    return
$value1;
}
?>



Query2Report : Generating Html, Pdf and Csv Reports from SQL Query
Categories : PHP, PHP, HTML, PDF, Excel
A Simple Script that converts IP addresses to Color Codes -This function converts a given IP into a hex color. It changes according to ip input. Very useful to create customised pages.
Categories : PHP, BC math
bcadd -- Add two arbitrary precision numbers
Categories : PHP, PHP Functions, BC math
Arbitrary Precision Math using BCMATH routines
Categories : PHP, Math., BC math
Fast PI calculator. Can easily find the 1000th decimal place of pi in 5 seconds.
Categories : PHP, BC math, Algorithms
calculus of the eastersunday
Categories : BC math, PHP, Date Time, Databases
How to implement a session tracking system.
Categories : PHP, Sessions, Variables
Problem with Database Connectivity in PHP and MS Access? Don't worry, The easy way is......
Categories : ADO, PHP, Databases
STR - a Perl-like string manipulator class - The str class provides 4 perl-like methods for manipulating strings and other scalar variables.
Categories : PHP, PHP Classes, Perl, Strings
Popup window creator for images on the Fly.
Categories : PHP, GD image library, Java Script
PHP based Contact email form with multiple recipients, text file based, supports departments.
Categories : PHP, Email, Beginner Guides, Filesystem
SubmitForce URL power submitter (searchengine submission class)
Categories : PHP, Search Engines, URLs, PHP Classes
usercounter class
Categories : PHP, PHP Classes, Databases, MySQL, Environment Variables
Functions to access a NNTP/NNRP newsserver. Complete set with examples is at ftp://ftp.nederland.net/pub/nnrplib
Categories : Search, PHP, Complete Programs
Script to check values being submitted by POST or GET method from a form. This script may help diagnose what variables are being supplied by a browser to other php scripts.
Categories : HTML, Variables, Debugging, PHP, HTTP