Киритиш ва чиқариш оқимлари


(Xn) X ning n chi darajaga ko’tarish funksiyasi


Download 162.64 Kb.
bet5/5
Sana27.01.2023
Hajmi162.64 Kb.
#1132769
1   2   3   4   5
Bog'liq
Dasturlash C 5-maruza

(Xn) X ning n chi darajaga ko’tarish funksiyasi

 

double step (double x, int n)

{ if(!n) return 1;

else return x*step (x, n-1);

}

 

  •  

EKUBini topuvchi dastur tuzing

  • Ikkita a va b sonlari berilgan ularning EKUBini topuvchi dastur tuzing.
  • EKUB inglizchada Greatest common divisor qisqacha gcd(a, b).
  • Masalan
  • gcd(25, 20) = 5;

    gcd(60, 70)=10.

Eramizdan oldingi 325 yilda tug’ilgan. Grek matematigi, geometriyaning otasi. Evklid algoritmi eng qadmgi algoritmlardan biri.

Eramizdan oldingi 325 yilda tug’ilgan. Grek matematigi, geometriyaning otasi. Evklid algoritmi eng qadmgi algoritmlardan biri.


Evklid
  • Evklid algoritmi bo’yicha:

  • gcd(a, b) =
  • Masalan:

  • gcd(124, 36)
  • a=124,b=36,b≠0. gcd(124,36)=gcd(36,124%36)=gcd(36, 16)
  • a=36, b=16, b≠0. gcd(36, 16)=gcd(16, 36%16)=gcd(16, 4)
  • a=16, b=4, b≠0. gcd(16, 4)=gcd(4, 16%4)=gcd(4, 0)
  • a=4, b=0. gcd(4, 0) = 4;
  • Demak gcd(124, 36)=4.

int gcd(int a, int b) {

if (b==0)

return a;

return gcd(b, a % b);

}

E’tiboringiz

uchun

rahmat


Download 162.64 Kb.

Do'stlaringiz bilan baham:
1   2   3   4   5




Ma'lumotlar bazasi mualliflik huquqi bilan himoyalangan ©fayllar.org 2024
ma'muriyatiga murojaat qiling