Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace NestexExam_n6
- {
- class Program
- {
- static void Main(string[] args)
- {
- string command = Console.ReadLine();
- int sumOfPrime = 0;
- int sumOfNonPrime = 0;
- int min = int.MinValue;
- int max = int.MaxValue;
- while ( command != "stop")
- {
- for (int i = min; i <= max; i++)
- {
- int n = int.Parse(Console.ReadLine());
- if ( n < 0)
- {
- Console.WriteLine("Number is negative.");
- continue;
- }
- if ( n / 1 == n || n / n == 1)
- {
- sumOfPrime += n;
- }
- else
- {
- sumOfNonPrime += n;
- }
- }
- }
- Console.WriteLine($"Sum of all prime numbers is: {sumOfPrime}");
- Console.WriteLine($"Sum of all non prime numbers is: {sumOfNonPrime}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement