Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- namespace ConsoleApp1
- {
- class Program
- {
- static void Main(string[] args)
- {
- int primeSum = 0;
- int nonPrimeSum = 0;
- string command = Console.ReadLine();
- for (int i = int.MinValue; i <= int.MaxValue; i++)
- {
- while (command != "stop")
- {
- int temp = int.Parse(command);
- if (temp < 0)
- {
- Console.WriteLine("This number is negative");
- }
- else
- {
- if (temp % temp == 0)
- {
- primeSum += temp;
- }
- else
- {
- nonPrimeSum += temp;
- }
- }
- }
- command = Console.ReadLine();
- }
- Console.WriteLine($"Sum of all prime numbers is: {primeSum}");
- Console.WriteLine($"Sum of all prime numbers is: {nonPrimeSum}");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement