1. Ana Sayfa
  2. Programlama Temelleri

C# Dersleri Obeb Okek Bulma Hesaplama

C# Dersleri Obeb Okek Bulma Hesaplama
1

C# ile girilen iki sayının Obeb(en büyük ortak bölen) ve Okek(en küçük ortak kat) değerlerini bulan program yapacağız. Hesaplama işlemi için kullanıcıdan iki sayı isteyip girilen sayılar üzerinde bir döngü içerisinde Obeb değerini bulupo daha sonra Okek değeri için okek(a,b) = (a * b)/ obeb(a,b) formülünü kullanacağız.
obeb

using System;
using System.Collections.Generic;
using System.Text;
namespace ConsoleApplication1
{
    class Program
    {
        static int ObebBul(int sayi1, int sayi2)
        {
            while (sayi1 != sayi2)
            {
                if (sayi1 > sayi2)
                    sayi1 = sayi1 - sayi2;
                //www.bilisimogretmeni.com
                if (sayi2 > sayi1)
                    sayi2 = sayi2 - sayi1;
            }
            return sayi1;
        }
        //www.bilisimogretmeni.com
        static int OkekBul(int sayi1, int sayi2)
        {
            return (sayi1 * sayi2) / ObebBul(sayi1, sayi2);
        }
 
        static void Main(string[] args)
        {
            Console.WriteLine("Obeb ve Okek Hesaplama Programı");
            //www.bilisimogretmeni.com
            Console.Write("Birinci Sayı: ");
            int a = Convert.ToInt32(Console.ReadLine());
            Console.Write("İkinci Sayı: ");
            int b = Convert.ToInt32(Console.ReadLine());
            int obeb = ObebBul(a, b);
            int okek = OkekBul(a, b);
            Console.WriteLine("nOBEB({0,4},{1,4}) = {2,6}", a, b, obeb);
            Console.WriteLine("nOKEK({0,4},{1,4}) = {2,6}", a, b, okek);
            Console.ReadKey();
        }
    }
}

Bu İçeriğe Tepkin Ne Oldu?
Subscribe
Bildir
guest

This site uses Akismet to reduce spam. Learn how your comment data is processed.

1 Yorum
Inline Feedbacks
View all comments
ser

obeb bulmak için iki sayıyı birbirinden mi çıkarıyorsun :D