We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 2fdf568 commit 0db8a34Copy full SHA for 0db8a34
1 file changed
10_Harshad_Number/C/jb1717/10_Harshad_Number_test.c
@@ -1,4 +1,5 @@
1
#include <stdio.h>
2
+#include <assert.h>
3
#include "10_Harshad_Number.h"
4
5
/*
@@ -7,12 +8,25 @@
7
8
int main(void)
9
{
10
int pretty = 0;
11
+ int idx = 0;
12
+ int sample[] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
13
+ 12, 18, 20, 21, 24, 27, 30, 36,
14
+ 40, 42, 45, 48, 50, 54, 60, 63,
15
+ 70, 72, 80, 81, 84, 90, 100, 102,
16
+ 108, 110, 111, 112, 114, 117, 120,
17
+ 126, 132, 133, 135, 140, 144, 150,
18
+ 152,153, 156, 162, 171, 180, 190,
19
+ 192, 195, 198, 200};
20
21
printf("Display all Harshad numbers between 1 and 200\n\n");
22
+
23
for (int i = 0; i < 201; ++i)
24
25
if (isHarshad(i))
26
27
+ // if a number is consider Harshad but not in the sample
28
+ assert(sample[idx++] == i);
29
30
printf("%d", i);
31
pretty++;
32
if (pretty % 5 == 0)
@@ -21,6 +35,6 @@ int main(void)
35
printf("\t");
36
}
37
- printf("\n\n=== END ===\n");
38
+ printf("\n\n=== END ===\n\n");
39
return (0);
40
0 commit comments