Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Kapricoño {
- static Scanner sc;
- public static void main(String[] args) {
- sc = new Scanner(System.in);
- System.out.println(isKapriCoño(sc.nextInt()) ? "Es kapricoño" : "No es kapricoño");
- }
- public static boolean isKapriCoño(int num) {
- String pow = "" + num * num;
- if (num == 1) return true;
- for (int i = 1; i < pow.length(); i++) {
- int numA = Integer.parseInt(pow.substring(0, i));
- int numB = Integer.parseInt(pow.substring(i, pow.length()));
- if (numB != 0) {
- if (numA + numB == num) {
- return true;
- }
- }
- }
- return false;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement