きったんの頭

/*
 * pe12.c
 * https://mind.kittttttan.info/c/pe12
 */

/* https://mind.kittttttan.info/c/divs */
#include "divs.h"

#include <stdio.h>
#include <math.h>

void pe12(unsigned long n) {
  unsigned long i, c, t;

  t = 1;
  i = 2;
  while ((c = cnt_divs(t)) < n) {
    t += i++;
  }

  printf("%lu\n", t);
}

int main() {
  unsigned long n;

  puts("Problem 12:");
  while (1) {
    if (scanf("%lu", &n) != 1) {
      scanf("%*s");
      puts("Input Number.");
    } else {
      if (!n) {
        break;
      }
      pe12(n);
    }
  }

  return 0;
}