标签:喇叭 else author 等于 size turn ring code ret
/**
* @ Author whimouse
* @ Date 2020/11/4 19:21
* @ Version 1.0
* @ Description:牵牛花(俗称喇叭花)
*
* 牵牛花即:各个位数的阶乘等于数本身
* 1.求出各个位的数
* 2.参数传递阶乘
* 3.判断各个位数阶乘之和是否与该数相等
*/
public class QianNiuHua { public static void main(String args[]) { //1.求出各个位的数 for (int i = 0; i < 1000; i++) { int a = i / 100; int b = (i / 10) % 10; int c = i % 10; // 2.参数传递阶乘 long x = jieCheng(a) + jieCheng(b) + jieCheng(c); //3.判断各个位数阶乘之和是否与该数相等 if (i == x) { System.out.println("牵牛花:"+i); } } } public static long jieCheng(int n) { long temp; if (n == 0 || n == 1) { temp = 1; } else { temp = n * jieCheng(n - 1); } return temp; } }
标签:喇叭 else author 等于 size turn ring code ret
原文地址:https://www.cnblogs.com/xw1181/p/13928358.html