UVA 10392 (暑假-数论- G - Factoring Large Numbers)

#include <cstdio>
#include <cmath>

int main() {
	long long num;
	while (scanf("%lld", &num) && num != -1) {
		for (long long i = 2; i <= sqrt(num); i++)
			while (num % i == 0)  {
				printf("    %lld\n", i);
				num /= i;
			}
		printf("    %lld\n\n", num);
	}
	return 0;
}

你可能感兴趣的:(UVA 10392 (暑假-数论- G - Factoring Large Numbers))