Write a small program to solve an interesting abnormal mathematical problem Code

Source: Internet
Author: User
This article describes how to write a small program to solve an interesting abnormal Olympiad question:

Six people were born in April 11 and all of them belong to cows. The product of their years is 17597125. what is the sum of their years?

If you are an expert in mathematics and have come up with a mathematical solution. Please leave your method in the comment below.

If you are a programming expert and come up with a better algorithm than the following, please leave your method behind.

If you think about it, but still do not understand it. Let's look at the following program.

class Gusse {    public static void main(String[] args){        int sut1=1,sut2=1,sut3=1,sut4=1,sut5=1,sut6=1;        long mul=0,sum=0;        for(sut1=1;sut1<=15;sut1++){            for(int n2=0;n2<=10;n2++){                sut2=sut1+n2*12;                for(int n3=0;n3<=10;n3++){                    sut3=sut1+n3*12;                    for(int n4=0;n4<=10;n4++){                        sut4=sut1+n4*12;                        for(int n5=0;n5<=10;n5++){                            sut5=sut1+n5*12;                            for(int n6=0;n6<=10;n6++){                                sut6=sut1+n6*12;                               if((mul=sut1*sut2*sut3*sut4*sut5*sut6)==17597125){                                   System.out.println("sut1="+sut1);                                    System.out.println("n2="+n2);                                    System.out.println("n3="+n3);                                    System.out.println("n4="+n4);                                    System.out.println("n5="+n5);                                    System.out.println("n6="+n6);                                    System.out.println("sum="+(sum=sut1+sut2+sut3+sut4+sut5+sut6));                                    break;                                }                            }                        }                    }                }             }       }           } }

Copy the program intact to notepad, and run it in java to get the result.

The above is the detailed content of the code used to write a small program to solve an interesting abnormal Olympics question. For more information, see other related articles in the first PHP community!

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.