Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2020
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ConsoleApp1
  4. {
  5. class Program
  6. {
  7. static void Main(string[] args)
  8. {
  9. int primeSum = 0;
  10. int nonPrimeSum = 0;
  11. string command = Console.ReadLine();
  12. for (int i = int.MinValue; i <= int.MaxValue; i++)
  13. {
  14.  
  15. while (command != "stop")
  16. {
  17. int temp = int.Parse(command);
  18.  
  19. if (temp < 0)
  20. {
  21. Console.WriteLine("This number is negative");
  22. }
  23. else
  24. {
  25. if (temp % temp == 0)
  26. {
  27. primeSum += temp;
  28. }
  29. else
  30. {
  31. nonPrimeSum += temp;
  32. }
  33. }
  34. }
  35. command = Console.ReadLine();
  36. }
  37. Console.WriteLine($"Sum of all prime numbers is: {primeSum}");
  38. Console.WriteLine($"Sum of all prime numbers is: {nonPrimeSum}");
  39. }
  40. }
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement