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

Source: Internet
Author: User
The number 1316 is expressed as the sum of two numbers, one of which is a multiple of 13 and the other is a multiple of 11. Algorithm analysis:

1316. Obviously, 1300 is a multiple of 13, but 16 is not a multiple of 11. it can be thought that the result is still a multiple of 13 after any number of 13 is subtracted from 1300, so long as 16 is added with the multiples of N 13 minus this and 11, the two numbers are solved. There may be more than one answer, but we only need one solution.

It is not difficult to observe: (16 + 13*3) + (1300-13*3) = 1316, but we need to implement it using code:
Copy codeThe code is as follows:
$ N = 1316;
$ I = 0; // minus the nth 13, initialize to 0
$ Y = 16 + 13 * $ I; // The 16 split from 1316 plus N 13, which is initialized as 16
While ($ y % 11! = 0) {// if the sum of 16 plus N and 13 cannot be divided into 11
$ I ++; // add another 13
$ Y = 16 + 13 * $ I;
}

Echo '$ x ='. ($ n-$ y ).'
';
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.