Advertisement
Guest User

Untitled

a guest
Oct 17th, 2019
80
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.99 KB | None | 0 0
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Threading.Tasks;
  6.  
  7. namespace Лабораторная2
  8. {
  9. class Program
  10. {
  11. public static int Euler (int n)
  12. {
  13. int res = n;
  14. for (int i = 2; i*i < n; i++ )
  15. {
  16. if (n % i == 0)
  17. {
  18. while (n % i == 0)
  19. {
  20. n /= i;
  21. }
  22. res -= res / i;
  23. }
  24. }
  25. if (n > 1)
  26. {
  27. res -= res / n;
  28. }
  29. return res;
  30. }
  31. static void Main(string[] args)
  32. {
  33. Console.WriteLine("Пожалуйста, введите число: ");
  34. int num = int.Parse(Console.ReadLine());
  35. int res = 0;
  36. res = Euler(num);
  37. Console.WriteLine($"Ответ: {res}");
  38. }
  39. }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement