Write a program to find square of the number and the sum of its digits if the square is divisble by the sum show the message india other wise show message not divisible
Answers
Answer:
square is an integer that is the square of an integer;[1] in other words, it is the product of some integer with itself. For example, 9 is a square number, since it equals {\displaystyle 3^{2}}3^2 and can be written as 3 × 3.
The usual notation for the square of a number n is not the product n × n, but the equivalent exponentiation n2, usually pronounced as "n squared". The name square number comes from the name of the shape. The unit of area is defined as the area of a unit square (1 × 1). Hence, a square with side length n has area n2. In other words, if a square number is represented by n points, the points can be arranged in rows as a square each side of which has the same number of points as the square root of n; thus, square numbers are a type of figurate numbers (other examples being cube numbers and triangular numbers).
Square numbers are non-negative. Another way of saying that a (non-negative) integer is a square number is that its square root is again an integer. For example, √9 = 3, so 9 is a square number.
A positive integer that has no perfect square divisors except 1 is called square-free.
For a non-negative integer n, the nth square number is n2, with 02 = 0 being the zeroth one. The concept of square can be extended to some other number systems. If rational numbers are included, then a square is the ratio of two square integers, and, conversely, the ratio of two square integers is a square, for example, {\displaystyle \textstyle {\frac {4}{9}}=\left({\frac {2}{3}}\right)^{2}}{\displaystyle \textstyle {\frac {4}{9}}=\left({\frac {2}{3}}\right)^{2}}.
Starting with 1, there are ⌊√m⌋ square numbers up to and including m, where the expression ⌊x⌋ represents the floor of the number x.
Answer:
import java.util.Scanner;
public class Prog
{
public static void main(String args[])
{
Scanner in = new Scanner (System.in);
int a,square,m, n, sum = 0;
System.out.print("Enter the number m:");
m = in.nextInt();
System.out.println("Enter the value of a");
a= in.nextInt();
square= a*a;
{
while(m > 0)
{
n = m % 10;
sum = sum + n;
m = m / 10;
}
}
int g= square/sum;
if( g==0)
System.out.println("india");
else
System.out.println("not divisible");
}
}