The 1316 is represented as a number of two, one of which is a multiple of 13, and the other is a multiple of 11, for which two numbers are called. _php instance

Source: Internet
Author: User
Algorithm Analysis:

1316, obviously 1300 is a multiple of 13, but 16 is not a multiple of 11, you can think of any minus n 13 multiples from 1300 and the result is still a multiple of 13, so as long as 16 plus this minus n 13 is a multiple of 11, the two numbers are solved, and the answer may be more than one. But we just want a couple of solutions.

Careful observation is not difficult to find: (16+13*3) + (1300-13*3) = 1316, but we need to use code to achieve:
Copy Code code as follows:

<?php
$n = 1316;
$i =0;//minus the nth 13, initialized to 0
$y =16+13* $i//1316 16 plus n 13, which is initialized to 16
while ($y%11!=0) {//if 16 plus n 13 and cannot divide 11
$i ++;//, add another 13.
$y =16+13* $i;
}

echo ' $x = '. ($n-$y). ' <br> ';
echo ' $y = '. $y;
?>

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.