The number 1316 is expressed as a two-digit number, one of which is a multiple of 13 and the other is a multiple of 11, which is two numbers. _php Tutorials

Source: Internet
Author: User
Algorithm Analysis:

1316, it is obvious that 1300 is a multiple of 13, but 16 is not a multiple of 11, you can think of any number from 1300 to subtract n 13 multiples of its result is still a multiple of 13, so long as 16 plus this minus n 13 multiples of its and is a multiple of 11, the answer may be more than one, But we just have to ask for a couple of solutions.

Careful observation is not difficult to find: (16+13*3) + (1300-13*3) = 1316, but we need to implement the code:
Copy CodeThe code is as follows:
$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 not divisible by 11
$i ++;//plus another 13.
$y =16+13* $i;
}

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

http://www.bkjia.com/PHPjc/323644.html www.bkjia.com true http://www.bkjia.com/PHPjc/323644.html techarticle algorithm Analysis: 1316, it is obvious that 1300 is a multiple of 13, but 16 is not a multiple of 11, you can think of 1300 from any of the multiples of n 13 is the result is still a multiple of 13, then as long as 16 plus this minus ...

  • Related Article

    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.