What is an automorphic number?
A number is called an automorphic number if and only if the square of the given number ends with the same number itself. For example, 25, 76 are automorphic numbers because their square is 625 and 5776, respectively and the last two digits of the square represent the number itself. Some other automorphic numbers are 5, 6, 36, 890625, etc.
#Output
#67
#68
#69
A number is called an automorphic number if and only if the square of the given number ends with the same number itself. For example, 25, 76 are automorphic numbers because their square is 625 and 5776, respectively and the last two digits of the square represent the number itself. Some other automorphic numbers are 5, 6, 36, 890625, etc.
#Output
#67
#68
#69
Java
Peterson Number Java Program In the following program, we have taken an array of factorial to quickly find the factorial. You can use the logic also. #Source_code #71
Steps to Find Peterson Number
* Read or initialize a number (n).
* Find the last digit (d) of the given number.
* Find the factorial (fact) of the digit.
* Add the factorial (fact) to a variable
* Repeat steps 2 to 4 until the given number becomes 0.
* Compare the sum with n. If both are equal, the given number is Peterson, else not.
#Output
#71
* Read or initialize a number (n).
* Find the last digit (d) of the given number.
* Find the factorial (fact) of the digit.
* Add the factorial (fact) to a variable
* Repeat steps 2 to 4 until the given number becomes 0.
* Compare the sum with n. If both are equal, the given number is Peterson, else not.
#Output
#71
Java
Sunny Number A number is called a sunny number if the number next to the given number is a perfect square. In other words, a number N will be a sunny number if N+1 is a perfect square. Let's understand it through an example. #Source_code #72
Steps to Find Sunny Number
The logic is very simple. To find the sunny number, we need only to check whether N+1 is the perfect square or not.
Read or initialize a number (num).
Add 1 to the given number i.e. num+1.
Find the square root of num+1.
If the square root is an integer, the given number is sunny, else not a sunny number.
Let's implement the above steps in a Java program.
#Output
#72
The logic is very simple. To find the sunny number, we need only to check whether N+1 is the perfect square or not.
Read or initialize a number (num).
Add 1 to the given number i.e. num+1.
Find the square root of num+1.
If the square root is an integer, the given number is sunny, else not a sunny number.
Let's implement the above steps in a Java program.
#Output
#72
Java
Sunny Number A number is called a sunny number if the number next to the given number is a perfect square. In other words, a number N will be a sunny number if N+1 is a perfect square. #Source_code #73
Steps to Find Sunny Number
The logic is very simple. To find the sunny number, we need only to check whether N+1 is the perfect square or not.
Read or initialize a number (num).
Add 1 to the given number i.e. num+1.
Find the square root of num+1.
If the square root is an integer, the given number is sunny, else not a sunny number.
#Output
#73
The logic is very simple. To find the sunny number, we need only to check whether N+1 is the perfect square or not.
Read or initialize a number (num).
Add 1 to the given number i.e. num+1.
Find the square root of num+1.
If the square root is an integer, the given number is sunny, else not a sunny number.
#Output
#73
Java
Fascinating Number Java Program The base condition to check whether a number is fascinating or not is that the number must have at least 3 or more than three digits. #Source_code #75
Steps to Find Fascinating Numbers
First, check the given number consist of three digits or not. If no, print cannot be a fascinating number.
Else, multiply the given number by 2 and 3, separately.
Convert the results (from step 2) into a string.
Concatenate the strings (from step 3) with the given number (n).
Iterate over the string that we get after concatenation and count the frequency of each digit.
Print "not a fascinating number" if any digit is missing or appeared multiple times. Else, print "fascinating number".
Let's implement the above steps in a Java program
#Output
#75
First, check the given number consist of three digits or not. If no, print cannot be a fascinating number.
Else, multiply the given number by 2 and 3, separately.
Convert the results (from step 2) into a string.
Concatenate the strings (from step 3) with the given number (n).
Iterate over the string that we get after concatenation and count the frequency of each digit.
Print "not a fascinating number" if any digit is missing or appeared multiple times. Else, print "fascinating number".
Let's implement the above steps in a Java program
#Output
#75
Java
#Source_code #76
Spy Number
A positive integer is called a spy number if the sum and product of its digits are equal. In other words, a number whose sum and product of all digits are equal is called a spy number.
#Output
#76
A positive integer is called a spy number if the sum and product of its digits are equal. In other words, a number whose sum and product of all digits are equal is called a spy number.
#Output
#76
Java
Sunny Number A number is called a sunny number if the number next to the given number is a perfect square. In other words, a number N will be a sunny number if N+1 is a perfect square. Let's understand it through an example. #Source_code #72
Steps to Find Sunny Number
The logic is very simple. To find the sunny number, we need only to check whether N+1 is the perfect square or not.
Read or initialize a number (num).
Add 1 to the given number i.e. num+1.
Find the square root of num+1.
If the square root is an integer, the given number is sunny, else not a sunny number.
Let's implement the above steps in a Java program.
#Output
#72
The logic is very simple. To find the sunny number, we need only to check whether N+1 is the perfect square or not.
Read or initialize a number (num).
Add 1 to the given number i.e. num+1.
Find the square root of num+1.
If the square root is an integer, the given number is sunny, else not a sunny number.
Let's implement the above steps in a Java program.
#Output
#72
Java
code.png
#Data_structure
#Output
#84
Example inputs for a given Data Structure:
Input:
string: codesleepcode
pattern: XYX
Output:
X: code
Y: sleep
Input:
string: codecodecode
pattern: XXX
Output:
X: code
#Output
#84
Example inputs for a given Data Structure:
Input:
string: codesleepcode
pattern: XYX
Output:
X: code
Y: sleep
Input:
string: codecodecode
pattern: XXX
Output:
X: code