きったんの頭ん中☆
/*
* pe3.c
* https://mind.kittttttan.info/c/pe3
*/
/* https://mind.kittttttan.info/c/divs */
#include "divs.h"
#include <stdio.h>
#include <stdint.h>
#include <stdlib.h>
#include <math.h>
#include <stddef.h>
#ifdef _WIN32
#define UINT64 "I64u"
#else
#define UINT64 "llu"
#endif
void pe3(uint64_t n) {
static const size_t MAX_DIVS_CNT = 128;
unsigned long p[MAX_DIVS_CNT];
size_t len;
len = get_divs(p, n);
if (len) {
printf("Max prime factor of %" UINT64 " is %lu\n", n, p[len - 1]);
} else {
printf("%" UINT64 " has no prime factors\n", n);
}
}
int main() {
uint64_t n;
puts("Problem 3:");
while (1) {
if (scanf("%" UINT64, &n) != 1) {
scanf("%*s");
puts("Input Number.");
} else {
if (!n) {
break;
}
pe3(n);
}
}
return 0;
}