-
Notifications
You must be signed in to change notification settings - Fork 18
/
Copy pathAdditive Prime Numbers.cs
65 lines (56 loc) · 1.71 KB
/
Additive Prime Numbers.cs
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
62
63
64
65
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Prime_numbers
{
class Program
{
static void Main(string[] args)
{
int i, j,k;
int sum = 0;
int rem;
int val;
for (i = 2; i <= 100; i++)
{
for (j = 2; j < i; j++)
{
if (i % j == 0)
{
break;
}
}
if (i == j)
{
int[] prime = { i };
foreach (int b in prime)
{
rem = i % 10;
val = i / 10;
sum = val + rem;
Console.WriteLine("The sum of digits of Prime number is:{0}={1}", i, sum);
}
int[] prime1 = { sum };
foreach (int c in prime1)
{
for (k = 2; k < c; k++)
{
if (c % k == 0)
{
break;
}
}
if (c == k)
{
Console.WriteLine("The Given Additive Prime number is also an Prime number:{0}", c);
Console.WriteLine("\n");
}
}
}
}
Console.ReadKey();
}
}
}