A special two-digit number is such that when the sum of the digits is added to the product of its digits, the result is equal to the original two-digit number.
import java.util.*;
class special_two_digit_no
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int n,t,r,sum,mul,add;
System.out.println("Enter the number");
n=sc.nextInt(); // suppose n=59
t=n; // Now t=59
r=n%10; // r=59%10=9
n=n/10; // n=59/10=5
sum=r+n; // sum=9+5=14
mul=r*n; // mul=9*5=45
add=sum+mul; // add=14+45=59
if(t==add) // if(59==59)
System.out.println("special two digit no");
else
System.out.println("Not special two digit no");
}
}
import java.util.*;
class special_two_digit_no
{
public static void main(String args[])
{
Scanner sc = new Scanner(System.in);
int n,t,r,sum,mul,add;
System.out.println("Enter the number");
n=sc.nextInt(); // suppose n=59
t=n; // Now t=59
r=n%10; // r=59%10=9
n=n/10; // n=59/10=5
sum=r+n; // sum=9+5=14
mul=r*n; // mul=9*5=45
add=sum+mul; // add=14+45=59
if(t==add) // if(59==59)
System.out.println("special two digit no");
else
System.out.println("Not special two digit no");
}
}