about summary refs log tree commit diff
path: root/others/mHoang/pfactor.c
blob: fee50b58baba45826cac60da13d939974c3b04be (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#include <stdio.h>
#include <math.h>

int main()
{
	long long n, sqrtn;
	long i, tmp;

	scanf("%lld", &n);
	sqrtn = sqrt(n);

	for (i = 2; i <= sqrtn && n > 1; i++)
		while (n % i == 0) {
			n /= i;
			tmp = i;
		}

	printf("%lld\n", (n == 1) ? tmp : n);

	return 0;
}