Karekök Fonksiyonunun Algoritması?
-
Merhaba arkadaşlar,
Karekök almanın algoritmasını pseudo code şeklinde yazabilir misiniz?
-
Wiki
cnr437 tarafından 19/May/13 19:34 tarihinde düzenlenmiştir
http://en.wikipedia.org/wiki/Methods_of_computing_square_roots
short isqrt(short num) { short res = 0; short bit = 1 << 14; // The second-to-top bit is set: 1L< // "bit" starts at the highest power of four <= the argument. while (bit > num) bit >>= 2; while (bit != 0) { if (num >= res + bit) { num -= res + bit; res = (res >> 1) + bit; } else res >>= 1; bit >>= 2; } return res; }
pythonda ise şöyle,
def sqrt(number):
s = number ** 0.5
return s
:D -
pseudo şeklinde veremez misin hocam?
-
newton raphson ile karekök alabilirsin.
Toplam Hit: 1487 Toplam Mesaj: 4