salih
New member
- Joined
- Sep 12, 2019
- Messages
- 2
- Programming Experience
- Beginner
I wanted to print the numbers where t, p, and h were equal, but the program print all t numbers.
Where is my fault ?
thanks for your future answers and sorry for my english.
Where is my fault ?
thanks for your future answers and sorry for my english.
C#:
static void Main(string[] args)
{
ulong num = 0, k = 0,s=0;
ulong[] tnum = new ulong[10000];
ulong[] pentnum = new ulong[10000];
ulong[] hexnum = new ulong[10000];
ulong[] sonuc = new ulong[10];
while (pentnum[9999] == 0)
{
num++;
tnum[k] = num * (num + 1) / 2;
hexnum[k] = num * (3 * num - 1) / 2;
pentnum[k] = num*(2 * num - 1);
k++;
}
foreach (ulong t in tnum)
{
foreach (ulong h in pentnum)
{
if(t == h)
{
foreach (ulong p in pentnum)
{
if(t == p && t == h)
{
Console.WriteLine(t);
}
}
}
}
}
Console.Read();
}