/home/toolbox/public_html/solutions/106/10680/b.c
1 #include <stdio.h>
2 #include <string.h>
3 #include <sys/types.h>
4 #include <sys/stat.h>
5 #include <fcntl.h>
6 #include <stdint.h>
7 #include <math.h>
8 #include <stdlib.h>
9
10 #define TRUE (1 == 1)
11 #define FALSE (1 != 1)
12
13 #define DEBUG if (FALSE)
14
15 /*
16 * Author: Isaac Traxler
17 * Date: 2020-03-05
18 * Purpose: fun
19 * Problem: 10680 - LCM
20 */
21
22 /*
23 * This template reads data until a terminating value is reached.
24 */
25
26 #define MAX_VALUE 1000001
27
28 int arr[MAX_VALUE+3];
29 int num;
30
31 void init()
32 {
33 /* FUNCTION init */
34 int i;
35 int tmp;
36
37 arr[1]=1;
38 i = 1;
39 for (; MAX_VALUE>i;)
40 {
41 /* for each poisble vlue */
42 tmp = arr[i];
43 i++;
44 tmp = tmp * i;
45 while (0 == (tmp % 10))
46 {
47 tmp = tmp / 10; /* clear off trailing 0s */
48 }
49 arr[i] = tmp % 10;
50 } /* for each poisble vlue */
51 } /* FUNCTION init */
52
53 void dump()
54 {
55 /* FUNCTION dump */
56 } /* FUNCTION dump */
57
58 int getInput()
59 {
60 /* FUNCTION getInput */
61 int dataReadFlag;
62
63 scanf(" %d ", &num);
64 dataReadFlag = 0!= num;
65 return (dataReadFlag);
66 } /* FUNCTION getInput */
67
68 void process()
69 {
70 /* FUNCTION process */
71 printf("%d: ", num);
72 printf("%d\n", arr[num]);
73 } /* FUNCTION process */
74
75 int main()
76 {
77 /* main */
78 int moreToDo;
79
80 init();
81 moreToDo = getInput();
82 while (moreToDo)
83 {
84 /* while */
85 process();
86 moreToDo = getInput();
87 } /* while */
88
89 return EXIT_SUCCESS;
90 } /* main */
91