forked from anish-mishr/specialNumbers
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSunnyNumber.java
More file actions
27 lines (25 loc) · 971 Bytes
/
Copy pathSunnyNumber.java
File metadata and controls
27 lines (25 loc) · 971 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
package specialNumbers;
/**
* @author Anish
*
*
*/
public class SunnyNumber {
/* Sunny Number is a number if the square root of the number N+1 is an integer number.
* i.e., sqrt(N+1)%1 == 0
* for example 24 is a sunny number because 24+1 = 25 has a square root of 5 which is an integer.
*/
public static void sunnyNumber(int num) { // Static Method
if((Math.sqrt(num+1)) % 1 == 0) // Checks the condition for Sunny Number
System.out.println(">> "+ num +" is Sunny Number"); // IF TRUE prints Sunny Number
else
System.out.println(">> "+ num +" is NOT Sunny Number"); // IF not TRUE prints NOT Sunny number
}
// MAIN METHOD
public static void main(String[] args) {
// Input is another public class having getNumber STATIC Method and a return type of INTEGER
System.out.println(" Find A Number is Sunny or NOT");
int num = Input.getNumber(); // gets the NUM
sunnyNumber(num); // Static method to check number is Sunny or Not
}
}