• Register
0 votes
211 views

Problem :

Write an expression that prints "special number" if specialnum is -99, 0, or 44.

6 5 3
7,540 points

Please log in or register to answer this question.

1 Answer

0 votes

Solution :

A Special Number is also called as Krishnamurthy number and Strong number.

The Number is called special number when the sum of the factorial of its digits

is equal to the number itself.

Please find below the examples of the numbers which are Special

Number to be checked : 145 
1! + 4! + 5! = 1 + 24 + 120 = 145   // 145 is the Special Number
Number to be checked : 2 
2!  = 2 = 2   // 2 is the Special Number
Please find below the examples of numbers which are NOT the Special number

Number to be checked : 35

3! + 5! = 6 + 120 = 126   // 35 is NOT the Special Number

Number to be checked : 105

1! + 0! + 5! = 1 + 1 + 120 = 122   // 105 is NOT the Special Number

 

Please find below the program in java for your query.

import java.util.*;

public class SpecialNumberJava

{

public static void main(String args[])

{

Scanner sc =new Scanner(System.in);

System.out.println(“Please enter your number”);

int no=sc.nextInt();

int check=no,mod=0,fact=1,sum=0;

while(no!=0)

{

mod=no%10;

no=no/10;

fact=1;

for(int i=mod;i>0;i--)

{

fact=fact*i;

}

sum=sum+fact;

}

if(check==sum)

{

System.out.println("The number is special number:"+sum);

}

else

{

System.out.println("The number is not special number:"+sum);

}

}

}

 

9 7 4
38,600 points

Related questions

0 votes
1 answer 6 views
6 views
Problem: Hello programmers! I am a beginner and I have got an assginement in which I have to write a program in Java that will take a number from user as input and will check whether the user entered an even number or an odd number. The program is to be written in ... and I have no idea how to check if a number is even or odd using a program. Any help from you would be much appreciated. Thanks
asked Nov 27, 2020 Code Learner 5.2k points
1 vote
1 answer 131 views
131 views
Problem: Can anyone provide me an expression that executes the loop body as long as the user enters a non-negative number. Thanks in advance.
asked Apr 9, 2020 LizzyM 6.1k points
0 votes
1 answer 90 views
90 views
Solutions: I am new in programming and my logic is not good, can anyone give the right solution? Write an expression that evaluates to true if and only if the C-string s equals the C-string "end"?
asked Feb 14, 2020 maddi86 5.4k points
3 votes
1 answer 2.8K views
2.8K views
Problem: Hello good soul, I am a student of basic java programming. I was solving beginner-level problems from there. Right now I got a problem that says, write a program that squares an integer and prints the result. Well, I am not one of those who always look solution for their assignment on StackOverflow or other sites. I just want to learn the process. Thanks for your help.
asked Mar 24, 2020 Gavin 15.3k points
0 votes
1 answer 24 views
24 views
Problem: I am new to programming, I need help, can anyone help me? Write an expression that evaluates to True if and only if s refers to the str "end"?
asked Feb 18, 2020 maddi86 5.4k points
0 votes
1 answer 160 views
160 views
Problem: I am new in programming and stuck in a query, can anyone guide me? Write an expression that evaluates to True if the str associated with s starts with "p"?
asked Feb 17, 2020 maddi86 5.4k points
0 votes
1 answer 5 views
5 views
Problem: Hello! I am a beginner and got an assignment for writing an expression that returns the last digit of an integer number. I got no idea how to do that. I have seen the solutions of many fellows, which was number % 10, or something like this but could not understand their answers. If any of you could give the solution with a detailed explanation of that, I would be so grateful. Thanks!
asked Nov 30, 2020 Code Learner 5.2k points
0 votes
1 answer 66 views
66 views
Problem: Can anyone help it was actually asked in exam as following and I need to know whether my answer was right or not? Write an expression that whose value is the fifth character of the String name?
asked Feb 24, 2020 maddi86 5.4k points
0 votes
1 answer 4 views
0 votes
1 answer 15 views
15 views
Problem this is the problem /* evenBitParity - returns 1 if an odd number of the even-indexed bits of x are 0's (bit 0 of x is the 1's place) Examples: evenBitParity(0) = 0 (16 zero even-indexed bits), evenBitParity(2) = 0 (16 zero even-indexed bits, bit 1 is non-zero but not even-indexed) evenBitParity(3) = 1 (15 ... x ^ (x >> 2); x = x ^ (x >> 4); x = x ^ (x >> 8); x = x ^ (x >> 16); return x&1;
asked Sep 15, 2020 Marivoke 530 points