MH
MH
CC#
Created by MH on 10/8/2024 in #help
✅ stuck on getting 20 prime numbers C#
thank you so much
170 replies
CC#
Created by MH on 10/8/2024 in #help
✅ stuck on getting 20 prime numbers C#
you are too good of a teacher
170 replies
CC#
Created by MH on 10/8/2024 in #help
✅ stuck on getting 20 prime numbers C#
thanks
170 replies
CC#
Created by MH on 10/8/2024 in #help
✅ stuck on getting 20 prime numbers C#
I got rid of this too for (i = 1; i <= 20; i++)
170 replies
CC#
Created by MH on 10/8/2024 in #help
✅ stuck on getting 20 prime numbers C#
prime sum:639
170 replies
CC#
Created by MH on 10/8/2024 in #help
✅ stuck on getting 20 prime numbers C#
//
static void Main(string[] args)
{
int n = 1, i = 0, div = 0, sum = 0, x, y=0;

for (i = 1; i <= 20; i++)
{
for (n = 1; n <= 500; n++)
{
for (x = 1; x <= n; x++)
{
if (n % x == 0)
{
div++;
}
}
if (div == 2)
{
sum=sum+n;
y++;
}
div = 0;
if (y == 20)
{
break;
}
}

}
Console.WriteLine("prime sum:" + sum);
Console.ReadKey();
}
}
}
//
static void Main(string[] args)
{
int n = 1, i = 0, div = 0, sum = 0, x, y=0;

for (i = 1; i <= 20; i++)
{
for (n = 1; n <= 500; n++)
{
for (x = 1; x <= n; x++)
{
if (n % x == 0)
{
div++;
}
}
if (div == 2)
{
sum=sum+n;
y++;
}
div = 0;
if (y == 20)
{
break;
}
}

}
Console.WriteLine("prime sum:" + sum);
Console.ReadKey();
}
}
}
170 replies
CC#
Created by MH on 10/8/2024 in #help
✅ stuck on getting 20 prime numbers C#
nice
170 replies
CC#
Created by MH on 10/8/2024 in #help
✅ stuck on getting 20 prime numbers C#
now it only prints 20 primes
170 replies
CC#
Created by MH on 10/8/2024 in #help
✅ stuck on getting 20 prime numbers C#
//
static void Main(string[] args)
{
int n = 1, i = 0, div = 0, sum = 0, x, y=0;

for (i = 1; i <= 20; i++)
{
for (n = 1; n <= 500; n++)
{
for (x = 1; x <= n; x++)
{
if (n % x == 0)
{
div++;
}
}
if (div == 2)
{
Console.WriteLine(n);
y++;
}
div = 0;
if (y == 20)
{
break;
}
}

}
Console.ReadKey();
}
}
}
//
static void Main(string[] args)
{
int n = 1, i = 0, div = 0, sum = 0, x, y=0;

for (i = 1; i <= 20; i++)
{
for (n = 1; n <= 500; n++)
{
for (x = 1; x <= n; x++)
{
if (n % x == 0)
{
div++;
}
}
if (div == 2)
{
Console.WriteLine(n);
y++;
}
div = 0;
if (y == 20)
{
break;
}
}

}
Console.ReadKey();
}
}
}
170 replies
CC#
Created by MH on 10/8/2024 in #help
✅ stuck on getting 20 prime numbers C#
ok
170 replies
CC#
Created by MH on 10/8/2024 in #help
✅ stuck on getting 20 prime numbers C#
should I add another variable?
170 replies
CC#
Created by MH on 10/8/2024 in #help
✅ stuck on getting 20 prime numbers C#
so we wont get anymore Ns
170 replies
CC#
Created by MH on 10/8/2024 in #help
✅ stuck on getting 20 prime numbers C#
N
170 replies
CC#
Created by MH on 10/8/2024 in #help
✅ stuck on getting 20 prime numbers C#
no no
170 replies
CC#
Created by MH on 10/8/2024 in #help
✅ stuck on getting 20 prime numbers C#
the one that generates X?
170 replies
CC#
Created by MH on 10/8/2024 in #help
✅ stuck on getting 20 prime numbers C#
X?
170 replies
CC#
Created by MH on 10/8/2024 in #help
✅ stuck on getting 20 prime numbers C#
but where?
170 replies
CC#
Created by MH on 10/8/2024 in #help
✅ stuck on getting 20 prime numbers C#
oh right
170 replies
CC#
Created by MH on 10/8/2024 in #help
✅ stuck on getting 20 prime numbers C#
how
170 replies
CC#
Created by MH on 10/8/2024 in #help
✅ stuck on getting 20 prime numbers C#
and sum the prime numbers right?
170 replies