Java programming ideology _ 009 vampire numbers

Source: Internet
Author: User
Package COM. WZS; // a vampire number refers to a number with an even number. It can be obtained by multiplying a pair of values and a value ending with two zeros is not allowed. // For example: 1260 = 21*60 1827 = 21*87 2187 = 27*81 public class test {public static void main (string [] ARGs) {for (INT I = 1000; I <9999; I ++) {isbloodsucker (I, COM (a (I), B (I), COM (C (I), D (I ))); isbloodsucker (I, COM (a (I), B (I), COM (d (I), C (I); isbloodsucker (I, COM (a (I), C (I), COM (B (I), D (I); isbloodsucker (I, COM (a (I ), C (I), COM (d (I), B (I); isbloodsucker (I, COM (a (I), D (I )), COM (B (I), C (I); isbloodsucker (I, COM (a (I), D (I), COM (C (I ), B (I); isbloodsucker (I, COM (B (I), A (I), COM (C (I), D (I ))); isbloodsucker (I, COM (B (I), A (I), COM (d (I), C (I); isbloodsucker (I, COM (B (I), C (I), COM (d (I), A (I); isbloodsucker (I, COM (B (I ), d (I), COM (C (I), A (I); isbloodsucker (I, COM (C (I), A (I )), COM (d (I), B (I); isbloodsucker (I, COM (C (I), B (I), COM (d (I ), A (I) ;}}// determine whether the vampire number is static void isbloodsucker (int I, int M, int N) {if (I = m * n) {system. out. println (I + "=" + M + "*" + n) ;}// combine them into two-digit static int COM (int I, Int J) {return (I * 10) + J;} // thousands of static int A (int I) {return I/1000;} // hundreds of static int B (int I) {return (I % 1000)/100;} // ten static int C (int I) {return (I % 1000) % 100)/10 ;} // single-digit static int D (int I) {return (I % 1000) % 100) % 10 ;}}

Output result:

 
1260 = 21*601395 = 15*931435 = 41*351530 = 51*301827 = 87*212187 = 27*816880 = 86*806880 = 80*86

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.