# Challenge: Crazy Number

An Crazy number is an n-digit positive number such that the sum of its digits raised to the power n is the number itself. Write a program to check whether a number is Crazy number or not. If number is a Crazy number, print "Yes" else "No". See sample test case given below for more clarification. N.B: We are assuming all numbers given are in base 10. Input Specification: First input is an interger t denotes number of test cases. Next there will be t lines denoting t test cases. Each test case line will have a number N for which you have to check whether it is Crazy Number of not. Output Specification: Output contains t lines. ith line output will be either "Yes" or "No" depending on the number in ith test case. Constraints: 0 < t < 2^31 0 < N < 2^63 Sample Input: 3 153 12 1634 Sample Output: Yes No Yes Explanation: There are three test cases. First testcase: 153 is a 3 digit number. So 1^3 + 5^3 + 3^3 = = 1 + 125 + 27 = 153. So, 157 is Crazy number. Second testcase: 12 is a 2 digit number. So 1^2 + 2^2 = 1 + 4 = 5 != 12. So, 12 is not a Crazy number. Third testcase: 1634 is a 4 digit number. So 1^4 + 6^4 + 3^4 + 4^4 = 1 + 1296 + 81 + 256 = 1634. So, 1634 is a Crazy number. Hence the ouput is : Yes No Yes My Program: https://code.sololearn.com/cXme4sSLqqfu/#java /* Edit: Except few peoples everyone else write code for just a simple Armstrong Number Checker. All you need to read the question again specially the Input/output Specifications. and few coders like @Dipta @Rame#1 @Reniel @Yerucham @LukArToDo writes code according to input/output specication but only few of them passes this case ((Constraints: 0 < t < 2^31 0 < N < 2^63)) */

12/9/2017 2:12:30 AM

Я. ♨109 Answers

New Answer@Zeel Patel 24678050 and 24678051. In fact if a crazy number ends with zero the next number is also crazy!

I have done it using Java and C++. My Java code answers whether the entered number is crazy. But my C++ code lists all crazy numbers less than or equal the entered number. Here are my answers: https://code.sololearn.com/ckmra6Z601wV https://code.sololearn.com/cOXr2142DPqR

@Zeel Patel thats not true you can find other examples using my C++ code. run my code for 100000000

Here's my try in Python according to your specified input and output. https://code.sololearn.com/cgcFv51Gm1O3/?ref=app

@Rajesh i updated my version to 1.0 plzz check it soon https://code.sololearn.com/c2ObSc3bH9FS/?ref=app