Skip to content

Instantly share code, notes, and snippets.

@dodangquan
Last active October 27, 2016 17:45
Show Gist options
  • Save dodangquan/012fe1d559a4ed88db938f33934fcf6c to your computer and use it in GitHub Desktop.
Save dodangquan/012fe1d559a4ed88db938f33934fcf6c to your computer and use it in GitHub Desktop.
Phân tích số nguyên tố dùng đệ qui
private static void dequi(int n, int i, int count) {
if (n == 1) {
return;
} else if (isPrime(i)) {
if (n % i == 0) {
count++;
n = n / i;
}
if (count == 0) {
++i;
}
else if (count > 0 && n % i != 0) {
System.out.println(i + " " + count); // In ra console
++i;
count = 0;
}
} else {
i++;
}
dequi(n, i, count);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment