fork(1) download
  1. using System;
  2.  
  3. public class Test
  4. {
  5. static int BeforeSpace(string before)
  6. {
  7. int length = before.Length;
  8. string output = "";
  9.  
  10. for (int i=0; i<length; i++)
  11. {
  12. if (!char.IsWhiteSpace(before[i]))
  13. {
  14. output += before[i];
  15. }
  16. else
  17. {
  18. return Convert.ToInt32(output);
  19. }
  20. }
  21. return 0;
  22. }
  23. static int AfterSpace(string after)
  24. {
  25. int length = after.Length;
  26. string output = "";
  27. bool startreading = false;
  28. for (int i=0; i<length; i++)
  29. {
  30. if (char.IsWhiteSpace(after[i]))
  31. {
  32. startreading = true;
  33. }
  34. if (startreading)
  35. {
  36. output+=after[i];
  37. }
  38. }
  39. return Convert.ToInt32(output);
  40. }
  41.  
  42. static bool isPrime(int value)
  43. {
  44. bool isPrime = true;
  45. int sqrt = Convert.ToInt32(Math.Sqrt(value));
  46. for (int i = 2; i<=sqrt; i++)
  47. {
  48. if ((value%i)==0)
  49. {
  50. isPrime = false;
  51. }
  52. }
  53. return isPrime;
  54. }
  55.  
  56. static void returnprime(int a, int b)
  57. {
  58. if (a==1)
  59. {
  60. a=2;
  61. }
  62.  
  63. for (; a<=b; a++)
  64. {
  65. if (isPrime(a))
  66. {
  67. Console.WriteLine(a);
  68. }
  69. }
  70. Console.WriteLine(Environment.NewLine);
  71. }
  72.  
  73. public static void Main()
  74. {
  75. int amount = Convert.ToInt32(Console.ReadLine());
  76.  
  77. for (int i = 0; i<amount; i++)
  78. {
  79. string textvalues = Console.ReadLine();
  80. int start_range = BeforeSpace(textvalues);
  81. int end_range = AfterSpace(textvalues);
  82. returnprime(start_range,end_range);
  83. }
  84. }
  85. }
Success #stdin #stdout 0.01s 131648KB
stdin
3
1 10
24 50
50 99
stdout
2
3
5
7


29
31
37
41
43
47


53
59
61
67
71
73
79
83
89
97