Ad
Code
Diff
  • import java.util.Arrays;
    
    public class Kumite {
      public static int powerOfPrimes(int num) {
    
        if(num <= 0) return 0;
        String numStr = Integer.toString(num);
    
        int sumEven = 0;
        int sumOdd = 0;
        int exponent = 0;
       
        for (int i = 0; i < numStr.length(); i++) {
    
          int digit = Character.getNumericValue(numStr.charAt(i));
          
          if(digit % 2 == 0) {
            sumEven += digit;
          } else {
            sumOdd += digit;
          }
    
          int[] primes = {2, 3, 5, 7};
          
          if(Arrays.binarySearch(primes, digit) >= 0) {
            exponent ++;
          }
          
        }
        return (int) Math.pow(sumEven - sumOdd, exponent);
      }
    }
    
    
    • import java.util.Arrays;
    • public class Kumite {
    • public static int powerOfPrimes(int num) {
    • if(num <= 0) return 0;
    • String numStr = Integer.toString(num);
    • int sumEven = 0;
    • int sumOdd = 0;
    • int base = 0;
    • int exponent = 0;
    • int result = 0;
    • for (int i = 0; i < numStr.length(); i++) {
    • int digit = Character.getNumericValue(numStr.charAt(i));
    • if(digit % 2 == 0) {
    • sumEven += digit;
    • } else {
    • sumOdd += digit;
    • }
    • int[] primes = {2, 3, 5, 7};
    • if(Arrays.binarySearch(primes, digit) >= 0) {
    • exponent ++;
    • }
    • }
    • base = sumEven - sumOdd;
    • result = (int) Math.pow(base, exponent);
    • return result;
    • return (int) Math.pow(sumEven - sumOdd, exponent);
    • }
    • }
Code
Diff
  • import java.util.Arrays;
    
    public class Kumite {
      public static int powerOfPrimes(int num) {
    
        if(num <= 0) return 0;
        String numStr = Integer.toString(num);
    
        int sumEven = 0;
        int sumOdd = 0;
        int base = 0;
        int exponent = 0;
        int result = 0;
    
        for (int i = 0; i < numStr.length(); i++) {
    
          int digit = Character.getNumericValue(numStr.charAt(i));
          
          if(digit % 2 == 0) {
            sumEven += digit;
          } else {
            sumOdd += digit;
          }
    
          int[] primes = {2, 3, 5, 7};
          
          if(Arrays.binarySearch(primes, digit) >= 0) {
            exponent ++;
          }
          
        }
        
        base = sumEven - sumOdd;
        result = (int) Math.pow(base, exponent);
    
        return result;
      }
    }
    
    
    • import java.util.Arrays;
    • public class Kumite {
    • public static int powerOfPrimes(int num) {
    • if(num <= 0) return 0;
    • String numStr = Integer.toString(num);
    • int sumEven = 0;
    • int sumOdd = 0;
    • int base = 0;
    • int exponent = 0;
    • int result = 0;
    • for (int i = 0; i < numStr.length(); i++) {
    • int digit = Character.getNumericValue(numStr.charAt(i));
    • if(digit % 2 == 0) {
    • sumEven += digit;
    • } else {
    • sumOdd += digit;
    • }
    • int[] primes = {2, 3, 5, 7};
    • if(Arrays.binarySearch(primes, digit) >= 0) {
    • exponent ++;
    • }
    • }
    • base = sumEven - sumOdd;
    • result = (int) Math.pow(base, exponent);
    • return result;
    • }
    • }
Code
Diff
  • import java.util.Arrays;
    
    public class Kumite {
      public static int powerOfPrimes(int num) {
    
        String numStr = Integer.toString(num);
    
        int sumEven = 0;
        int sumOdd = 0;
        int base = 0;
        int exponent = 0;
        int result = 0;
    
        for (int i = 0; i < numStr.length(); i++) {
          
          int digit = Character.getNumericValue(numStr.charAt(i));   
          
          if(digit % 2 == 0) {
            sumEven += digit;
          } else {
            sumOdd += digit;
          }
    
          int[] primes = {2, 3, 5, 7};
          
          if(Arrays.binarySearch(primes, digit) >= 0) {
            exponent ++;
          }  
        }   
        base = sumEven - sumOdd;
        result = (int) Math.pow(base, exponent);
    
        return result;
      }
    }
    
    
    • import java.util.Arrays;
    • public class Kumite {
    • public static int powerOfPrimes(int num) {
    • String numStr = Integer.toString(num);
    • int sumEven = 0;
    • int sumOdd = 0;
    • int base = 0;
    • int exponent = 0;
    • int result = 0;
    • for (int i = 0; i < numStr.length(); i++) {
    • int digit = Character.getNumericValue(numStr.charAt(i));
    • int digit = Character.getNumericValue(numStr.charAt(i));
    • if(digit % 2 == 0) {
    • sumEven += digit;
    • } else {
    • sumOdd += digit;
    • }
    • int[] primes = {2, 3, 5, 7};
    • if(Arrays.binarySearch(primes, digit) >= 0) {
    • exponent ++;
    • }
    • }
    • }
    • }
    • base = sumEven - sumOdd;
    • result = (int) Math.pow(base, exponent);
    • return result;
    • }
    • }