EKOK - Programlama (Seçenekler Yanlış)

Konusu 'Hatalı - Tekrarlanmış Sorular veya Çözümler (Faulty - Repeated Questions or Solutions)' forumundadır ve Honore tarafından 20 Mayıs 2025 başlatılmıştır.

Yüklüyor...
  1. Honore

    Honore Yönetici Yönetici

    Mesajlar:
    11.382
    Beğenileri:
    652
    Cinsiyet:
    Bay
    Meslek:
    Müh. (Elk./Bilg.)
    Hazırlayanın da yanlış çözdüğü için şıkları hatalı verdiği bir ÖZDEBİR sorusu:
    [​IMG]
    https://i.ibb.co/LdV1fQVK/EKOK.png
    https://www.facebook.com/photo/?fbid=10162806493872579&set=g.137856289571386&locale=tr_TR

    b = 24 Sayısının Pozitif Tam Sayı Bölenleri
    b = {1, 2, 3, 4, 6, 8, 12, 24}
    Kod:
     b        a = b + 2       a / (24 / b) Sayısı Pozitif Bir Tam Sayı mı?
    ---       ---------       --------------------------------------------
     1            3                 3 / (24 / 1) = 1 / 8 ∉ N^(+), Hayır
    
     2            4                 4 / (24 / 2) = 1 / 3 ∉ N^(+), Hayır
    
     3            5                 5 / (24 / 3) = 5 / 8 ∉ N^(+), Hayır
    
     4            6                 6 / (24 / 4) = 1 ∈ N^(+), Evet
    
     6            8                 8 / (24 / 6) = 2 ∈ N^(+), Evet
    
     8           10                10 / (24 / 8) = 10 / 3 ∉ N^(+), Hayır
    
    12           14                14 / (24 / 12) = 7 ∈ N^(+), Evet
    
    24           26                26 / (24 / 24) = 26 ∈ N^(+), Evet
    Σa = 6 + 8 + 14 + 26 = 54.

    Bilgisayar Programlamayla İlgilenen Öğrenciler İçin Fortran 2003 Uyarlaması:
    [​IMG]
    https://i.ibb.co/DDhvd32t/EKOK-Fortran.png

    Program:
    Kod:
    ! https://app.codeconvert.ai/code-generator?outputLang=Fortran sitesindeki
    ! yapay zekâ tarafından yazılmış Fortran 2003 Programının biraz düzeltip
    ! değiştirdiğim hali:
    program find_a
      implicit none
      integer :: a, b, c, toplam = 0
      integer :: possible_b
    
      print *, "Finding possible values for integer a..."
      print *, "Based on: LCM(a, 24 / b) = b + 2 and LCM(a, 24 / b) = a"
      print *, "Where a and b are different and positive integers."
      print *
    
      print *, "Possible values for a:"
      
      ! From the given equations:
      ! LCM(a, 24 / b) = b + 2
      ! LCM(a, 24 / b) = a
      ! This implies a = b + 2.
      ! Also, LCM(a, 24 / b) = a implies that a must be a multiple of (24 / b).
      ! Substituting a = b + 2, we need (b + 2) to be a multiple of (24 / b).
      ! This means LCM(b + 2, 24 / b) = b + 2.
    
      ! b must be a positive integer divisor of 24 for 24/b to be an integer.
      ! The positive divisors of 24 are 1, 2, 3, 4, 6, 8, 12, 24.
      ! We iterate through these possible values for b.
      do possible_b = 1, 24
        if (mod(24, possible_b) == 0) then
          b = possible_b
          a = b + 2
    
          ! Check conditions:
          ! 1. a and b are positive integers: b is positive from the loop, a = b + 2 is positive.
          ! 2. a and b are different: a = b + 2 implies a /= b for positive b.
          ! 3. 24 / b is an integer: Ensured by checking mod(24, possible_b) == 0.
          c = 24 / b
    
          ! Check the derived condition: LCM(a, c) = a
          if (lcm(a, c) == a) then
            print *, a; toplam=toplam+a
          end if
        end if
      end do
    
    print*,""
    write(6,10)"The sum of values for a = ", toplam
    10 format (a,i2)
    
    contains
    
      ! GCD function (Euclidean algorithm)
      integer function gcd(x, y) result(res)
        integer, intent(in) :: x, y
        !integer :: res
        integer :: temp_x, temp_y, remainder
    
        temp_x = abs(x)
        temp_y = abs(y)
    
        do while (temp_y /= 0)
          remainder = mod(temp_x, temp_y)
          temp_x = temp_y
          temp_y = remainder
        end do
        res = temp_x
      end function gcd
    
      ! LCM function
      integer function lcm(x, y) result(res)
        integer, intent(in) :: x, y
        ! integer :: res
        integer :: common_divisor
    
        ! Handle edge cases where x or y is zero (LCM is 0)
        if (x == 0 .or. y == 0) then
          res = 0
        else
          common_divisor = gcd(x, y)
          ! LCM(x, y) = (x * y) / GCD(x, y)
          ! Calculate as (x / GCD(x, y)) * y to avoid potential overflow
          ! Note: For this problem, x and y (a and c) will be positive.
          res = (x / common_divisor) * y
        end if
      end function lcm
    
    end program find_a
     
    : Fortran

  2. Benzer Konular: Programlama (Seçenekler
    Forum Başlık Tarih
    Hatalı - Tekrarlanmış Sorular veya Çözümler (Faulty - Repeated Questions or Solutions) Basamak Analizi - Programlama (Seçenekler Hatalı) 4 Eylül 2024
    Hatalı - Tekrarlanmış Sorular veya Çözümler (Faulty - Repeated Questions or Solutions) Tam ve Asal Sayılar - Programlama (Seçenekler Yanlış) 2 Mayıs 2021
    Hatalı - Tekrarlanmış Sorular veya Çözümler (Faulty - Repeated Questions or Solutions) Tam, Rasyonel ve Gerçel Sayılar - Türev - Programlama (Seçenekler Hatalı) 28 Nisan 2021
    Hatalı - Tekrarlanmış Sorular veya Çözümler (Faulty - Repeated Questions or Solutions) Permütasyon (Seçenekler Yanlış) - Programlama 22 Kasım 2020
    Hatalı - Tekrarlanmış Sorular veya Çözümler (Faulty - Repeated Questions or Solutions) Tam Sayılar - Doğal Sayılar - Bölünebilme - Programlama (Seçenekler Yanlış) 10 Kasım 2020

Sayfayı Paylaş