Write C# program
(a) (8%) Write a C# method (function) primeNumber that checks if a positive integer k you input is a prime number. (b) (6%) Write C# program (with Main method) that uses your primeNumber method, to print out all the prime numbers from 2 until 200 with 8 prime numbers printed in a row (note 200 is NOT a prime number, so this means until the largest prime number <200). Enhance your program to also print out how many prime numbers are <200. (c) (12%) Generalize your program of part (b) to take an integer n> 1 from you that calculates all the prime numbers from 2 up to n. (so n = 200 as in part (b) is a particular case of part (c)) Since there may be too many prime numbers printed when n is big, customize your program this way: When n < 500, print prime numbers starting from 2, until n, 8 in a row. Also, print out the total number of such prime numbers When n >= 500, print out just the total number of such prime numbers (but do NOT print out prime numbers 8 in a row). Test your program with three integers, n = 400, n = 1,000, and a third integer of your choice.
Write C# program
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am