Advertisement
Guest User

Untitled

a guest
Apr 22nd, 2019
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.29 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 Zadatak2
  8. {
  9. class Program
  10. {
  11. static void Main(string[] args)
  12. {
  13. Console.Write("Upisite prvi broj: ");
  14. int broj1 = int.Parse(Console.ReadLine());
  15. Console.Write("Upisite drugi broj: ");
  16. int broj2 = int.Parse(Console.ReadLine());
  17. int umnozak = 1;
  18.  
  19. for(int i = 1; i <= Math.Max(broj1, broj2); i++)
  20. {
  21. if (broj1 % i == 0 || broj2 % i == 0)
  22. {
  23. umnozak *= i;
  24. if (broj1 % i == 0 && broj2 % i == 0)
  25. {
  26. broj1 = broj1 / i;
  27. broj2 = broj2 / i;
  28. }
  29. else if (broj1 % i == 0)
  30. broj1 = broj1 / i;
  31. else if (broj2 % i == 0)
  32. broj2 = broj2 / i;
  33. }
  34. }
  35. if (broj1 != 1)
  36. umnozak *= broj1;
  37. if (broj2 != 1)
  38. umnozak *= broj2;
  39.  
  40. Console.WriteLine("Visekratnik ova dva broja je broj {0}", umnozak);
  41.  
  42. }
  43. }
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement