Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- namespace Zadatak2
- {
- class Program
- {
- static void Main(string[] args)
- {
- Console.Write("Upisite prvi broj: ");
- int broj1 = int.Parse(Console.ReadLine());
- Console.Write("Upisite drugi broj: ");
- int broj2 = int.Parse(Console.ReadLine());
- int umnozak = 1;
- for(int i = 1; i <= Math.Max(broj1, broj2); i++)
- {
- if (broj1 % i == 0 || broj2 % i == 0)
- {
- umnozak *= i;
- if (broj1 % i == 0 && broj2 % i == 0)
- {
- broj1 = broj1 / i;
- broj2 = broj2 / i;
- }
- else if (broj1 % i == 0)
- broj1 = broj1 / i;
- else if (broj2 % i == 0)
- broj2 = broj2 / i;
- }
- }
- if (broj1 != 1)
- umnozak *= broj1;
- if (broj2 != 1)
- umnozak *= broj2;
- Console.WriteLine("Visekratnik ova dva broja je broj {0}", umnozak);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement