From c67182c04491f2cf8b67e78b68aebf32aea25470 Mon Sep 17 00:00:00 2001 From: Raphael McSinyx Date: Sun, 1 Jan 2017 20:42:05 +0700 Subject: Update others/{mHoang,mkcal} --- others/mHoang/pfactor.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 others/mHoang/pfactor.c (limited to 'others/mHoang/pfactor.c') diff --git a/others/mHoang/pfactor.c b/others/mHoang/pfactor.c new file mode 100644 index 0000000..fee50b5 --- /dev/null +++ b/others/mHoang/pfactor.c @@ -0,0 +1,21 @@ +#include +#include + +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; +} -- cgit 1.4.1