#7169: 到底錯在哪裡啊啊啊


abrcdf102 (彥欣)



import java.util.Scanner;

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {


        Scanner input = new Scanner(System.in);
        int n = input.nextInt();

       
        for (int i = 2; i <= n; i++) {
            int count = 0;
            while (n % i == 0) {
                n /= i;
                count++;
            }
            if (count > 0) {
                if (count == 1) {
                    System.out.print(i);
                } else {
                    System.out.print(i + "^" + count);
                }

                if (n > 1) {
                    System.out.print(" * ");
                }
            }
        }

    }
}

#7943: Re:到底錯在哪裡啊啊啊


bbence0411 (勤)



import java.util.Scanner;

public class Main {

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {


        Scanner input = new Scanner(System.in);
        int n = input.nextInt();

       
        for (int i = 2; i <= n; i++) {
            int count = 0;
            while (n % i == 0) {
                n /= i;
                count++;
            }
            if (count > 0) {
                if (count == 1) {
                    System.out.print(i);
                } else {
                    System.out.print(i + "^" + count);
                }

                if (n > 1) {
                    System.out.print(" * ");
                }
            }
        }

    }
}

String output = "";
int helf = input / 2;
for (int i = 2; i <= helf; i++) {
if (input % i == 0) {
int count = 0;
while (input % i == 0) {
count++;
input /= i;
}
if (count == 1) {
if (input == 1) {
output += i;
} else {
output += i + " * ";
}

} else {
if (input == 1) {
output += i + "^" + count;
} else {
output += i + "^" + count + " * ";
}
}
}
}
if (output.equals("")) {
output += input;
}
return output;