Question
%) Write a C# program that computes and prints the prime numbers starting from 2 until 500, with 8 in a row. At the end
%) Write a C# program that computes and prints the prime numbers starting from 2 until 500, with 8 in a row. At the end it also shows how many prime numbers there are from 2 to 500.
For your convenience, the method to check prime number is attached here.
public static bool isPrime(int k)
{ // method to check if k is a prime
for (int j = 2; j <= Math.Sqrt((double)k); j++) // Need to check up to square root only
if (k % j == 0) // if j divides k
return false;
return true;
}
(15%) Enhance the C# program so that you have an integer n input from the keyboard. Find the prime numbers from 2 till n like you do in part (a). Test with n = 256, 304, and 600.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started