我国古代数学家张丘建在《算经》一书中曾提出过著名的“百钱买百鸡”问题。 该问题叙述如下:鸡翁一,钱五;鸡母一,钱三;鸡雏三,钱一; 百钱买百鸡,则翁,母,雏各几何? ?php/** * $cock 鸡翁 $hen 母鸡 $chicken 小鸡 * 可得$cock + $hen + $chicken =
我国古代数学家张丘建在《算经》一书中曾提出过著名的“百钱买百鸡”问题。
该问题叙述如下:鸡翁一,值钱五;鸡母一,值钱三;鸡雏三,值钱一;
百钱买百鸡,则翁,母,雏各几何?
<?php /** * $cock 鸡翁 $hen 母鸡 $chicken 小鸡 * 可得$cock + $hen + $chicken = 100 * 百钱 5 * $cock + 3 * $hen + $chicken / 3 = 100 **/ for ($cock = 1; $cock < 20; $cock++) //$cock 鸡翁最多只有20只,因为有100只鸡,所以$cock < 20 { for ($hen = 1; $hen < 33; $hen++) //$hen 母鸡最多33只 $hen < 33 { $chick = 100 - $cock - $hen; //$chick 小鸡 if ( ($cock + $hen + $chick) == 100 && (5 * $cock + 3 * $hen + $chick / 3) == 100) { echo 'The cock: ', $cock, "; The hen: ", $hen, "; The chicken: ", $chick, "<br />"; } } } ?>特与大家分享。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

DVWA
Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software

VSCode Windows 64-bit Download
A free and powerful IDE editor launched by Microsoft

MinGW - Minimalist GNU for Windows
This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

ZendStudio 13.5.1 Mac
Powerful PHP integrated development environment

WebStorm Mac version
Useful JavaScript development tools