-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbasicClassification.c
More file actions
66 lines (54 loc) · 834 Bytes
/
basicClassification.c
File metadata and controls
66 lines (54 loc) · 834 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
#include <stdio.h>
#include "NumClass.h"
#include <math.h>
int factorial(int);
int isPrime(int num3){
if (num3 < 1)
{
return 0;
if (num3 == 1){
return 1;
}
}
for (int i = 2; i <= sqrt(num3); i++)
{
if (num3 % i == 0)
{
return 0;
}
}
return 1;
}
int isStrong(int num)
{
if (num == 0) {
return 0;
}
int temp = num;
int temp2;
int sum = 0;
while (temp > 0)
{
temp2 = (temp % 10);
sum += factorial(temp2);
temp = (temp / 10);
}
if (sum == num)
{
return 1;
}
return 0;
}
int factorial(int n)
{
if (n <= 0)
{
return 0;
}
int fact = 1;
for (int i = 1; i <= n; i++)
{
fact = fact * i;
}
return fact;
}