Number of daffodils

Source: Internet
Author: User

To find out all the "daffodils", the so-called "Narcissus number" refers to a three-digit number, whose numbers are cubic and equal to the number itself.

1 /**2 * Title: Print out all of the "daffodils", the so-called "Narcissus number" refers to a three-digit number, its number of cubes and equal to the number itself. 3 * For example: 153 is a "narcissus number", because the 153=1 three times the square +5 of three +3 Times Square. 4 * 1. Program Analysis: Use for loop control 100-999 number, each number decomposition out of bits, 10 bits, hundred. 5  * 6  */7  Public classDaffodilsdata {8      Public Static voidMain (string[] args) {9         intA, B, C, D;Ten         intdata; OneSystem.out.println ("The number of daffodils is:"); A          for(inti = 100; I < 999; i++) { -A = i/100; -b = (i-100 * a)/10; thec = i-100 * a-10 *b; -data = A * A * a + b * b * b + c * c *C; -             if(Data = =i) { - System.out.println (i); +             } -         } +     } A}

Number of daffodils

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.