Created
February 10, 2020 17:06
-
-
Save SanchitB23/05d3d2549cbd074b877478dcbf0aafb5 to your computer and use it in GitHub Desktop.
Go Rapid
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package practice.CodingQues.UnorderedQuestions; | |
import java.util.Scanner; | |
public class GandhiNumber { | |
public static void main(String[] args) { | |
Scanner scanner = new Scanner(System.in); | |
long num = scanner.nextInt(); | |
long temp = num; | |
long sum = 0; | |
while (temp > 0) { | |
sum += Math.pow(temp % 10, 4); | |
temp /= 10; | |
} | |
if (sum == num) System.out.println("It is a Gandhi Number"); | |
else System.out.println("It is not a Gandhi Number"); | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package practice.CodingQues.UnorderedQuestions; | |
//Write a code to find out all positive whole numbers x & y satisfying the equation x*y = 130 | |
public class XandYRelation { | |
public static void main(String[] args) { | |
for (int i = 1; i < 131; i++) { | |
for (int j = 1; j < 131; j++) { | |
if (i * j == 130) { | |
System.out.println("Res: " + i + "," + j); | |
} | |
} | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment