Guest User

Untitled

a guest
Jun 19th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. using System;
  2.  
  3. namespace ExpandNumberForum
  4. {
  5. class Program
  6. {
  7. public static void Main(string[] args)
  8. {
  9. string s = string.Empty;
  10. int b, c, n;
  11.  
  12. Console.WriteLine("Input number: ");
  13. if (!int.TryParse(Console.ReadLine(), out n)) return;
  14.  
  15. while ((n % 2) == 0)
  16. {
  17. n = n / 2;
  18. s += "2*";
  19. }
  20. b = 3; c = (int)Math.Sqrt(n) + 1;
  21. while (b < c)
  22. {
  23. if ((n % b) == 0)
  24. {
  25. if (n / b * b - n == 0)
  26. {
  27. s += b.ToString() + "*";
  28. n = n / b;
  29. c = (int)Math.Sqrt(n) + 1;
  30. }
  31. else
  32. b += 2;
  33. }
  34. else
  35. b += 2;
  36. }
  37. s += n.ToString();
  38. Console.WriteLine(s);
  39.  
  40. Console.Write("Press any key to continue . . . ");
  41. Console.ReadKey(true);
  42. }
  43. }
  44. }
  45.  
  46. r = a - a / b * b
Add Comment
Please, Sign In to add comment