{"id":131,"date":"2023-12-03T03:22:32","date_gmt":"2023-12-03T00:22:32","guid":{"rendered":"http:\/\/www.cuneytbayrak.com\/?p=131"},"modified":"2025-02-21T00:44:04","modified_gmt":"2025-02-20T21:44:04","slug":"faktoriyel-hesabinda-iteratif-yontem-mi-recursive-yontem-mi","status":"publish","type":"post","link":"http:\/\/www.cuneytbayrak.com\/?p=131","title":{"rendered":"Fakt\u00f6riyel Hesab\u0131nda \u0130teratif Y\u00f6ntem mi? Recursive Y\u00f6ntem mi?"},"content":{"rendered":"<p>Fakt\u00f6riyel hesab\u0131n\u0131 iteratif ve recursive y\u00f6ntemle daha evvel yapm\u0131\u015ft\u0131k. \u0130lgili yaz\u0131lara ar\u015fivden ula\u015fabilirsiniz. Peki ama hangi y\u00f6ntem daha h\u0131zl\u0131 sonu\u00e7 veriyor buna bir bakal\u0131m.<\/p>\n<p>Her iki y\u00f6ntem i\u00e7in kulland\u0131\u011f\u0131m python kodlar\u0131 a\u015fa\u011f\u0131da. Bir for d\u00f6ng\u00fcs\u00fc ile 100! den 500! e kadar 10 ar art\u0131rarak arada ki t\u00fcm say\u0131lar\u0131n fakt\u00f6riyelini buldum ve bunun i\u00e7in ge\u00e7en s\u00fcreleri bir diziye yazd\u0131rd\u0131m. Daha sonra \u00e7\u0131kan sonu\u00e7lar\u0131 bir grafik yard\u0131m\u0131 ile \u00e7izdirdim. Sonu\u00e7lar bekledi\u011fim gibi \u00e7\u0131kt\u0131. \ud83d\ude42<\/p>\n<p><strong>\u0130teratif Y\u00f6ntem \u0130\u00e7in Kulland\u0131\u011f\u0131m Kodlar:<\/strong><\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\"># Bu program fakt\u00f6ryel hesab\u0131n\u0131 iteratif y\u00f6ntemle yapar\r\nfrom timeit import default_timer as timer\r\n\r\n# Ba\u015flang\u0131\u00e7 de\u011feri\r\nn = 100\r\n\r\n# 100'den 500'e kadar 10 ad\u0131mlarla d\u00f6ng\u00fc\r\nfor x in range(n, 510, 10):\r\n    sonuc = 1\r\n    st = timer()  # Ba\u015flang\u0131\u00e7 zaman\u0131\r\n    for i in range(1, x + 1):\r\n        sonuc *= i  # Fakt\u00f6ryel hesaplama\r\n    et = timer()  # Biti\u015f zaman\u0131\r\n    exc = (et - st)  # Ge\u00e7en s\u00fcre\r\n    print(f\"{x}! fakt\u00f6ryelinin hesaplanma s\u00fcresi: {exc * 100000:.2f} mikrosaniye\")\r\n<\/pre>\n<\/div>\n<p><strong>Recursive Y\u00f6ntem \u0130\u00e7in Kulland\u0131\u011f\u0131m Kodlar:<\/strong><\/p>\n<div class=\"wp-block-codemirror-blocks code-block \">\n<pre class=\"CodeMirror\" data-setting=\"{&quot;mode&quot;:&quot;python&quot;,&quot;mime&quot;:&quot;text\/x-python&quot;,&quot;theme&quot;:&quot;material&quot;,&quot;lineNumbers&quot;:true,&quot;lineWrapping&quot;:false,&quot;styleActiveLine&quot;:false,&quot;readOnly&quot;:true,&quot;align&quot;:&quot;&quot;}\"># Bu program fakt\u00f6ryel hesab\u0131n\u0131 recursive y\u00f6ntemle yapar\r\nfrom timeit import default_timer as timer\r\n\r\n# Recursive fakt\u00f6riyel hesaplama fonksiyonu\r\ndef faktoriyel(n):\r\n    if n &lt;= 1:\r\n        return 1\r\n    else:\r\n        return faktoriyel(n - 1) * n\r\n\r\n# Ba\u015flang\u0131\u00e7 de\u011feri\r\nn = 100\r\n\r\n# 100'den 500'e kadar 10 ad\u0131mlarla fakt\u00f6riyel hesaplama\r\nfor x in range(n, 510, 10):\r\n    st = timer()  # Ba\u015flang\u0131\u00e7 zaman\u0131\r\n    sonuc = faktoriyel(x)  # Fakt\u00f6riyel hesaplama\r\n    et = timer()  # Biti\u015f zaman\u0131\r\n    exc = (et - st)  # Ge\u00e7en s\u00fcre\r\n    print(f\"{x}! fakt\u00f6ryelinin hesaplanma s\u00fcresi: {exc * 100000:.2f} mikrosaniye\")\r\n<\/pre>\n<\/div>\n<p>\u00c7\u0131kan s\u00fcreler milisaniye cinsindendir.<\/p>\n<p><strong>Sonu\u00e7:<\/strong><\/p>\n<p><a href=\"http:\/\/www.cuneytbayrak.com\/wp-content\/uploads\/2025\/02\/faktoriyel_iteratif_vs_recursive.jpg\" target=\"_blank\" rel=\"noopener\"><img loading=\"lazy\" decoding=\"async\" class=\"alignleft wp-image-132 size-large\" src=\"http:\/\/www.cuneytbayrak.com\/wp-content\/uploads\/2025\/02\/faktoriyel_iteratif_vs_recursive-1024x621.jpg\" alt=\"\" width=\"1024\" height=\"621\" srcset=\"http:\/\/www.cuneytbayrak.com\/wp-content\/uploads\/2025\/02\/faktoriyel_iteratif_vs_recursive-1024x621.jpg 1024w, http:\/\/www.cuneytbayrak.com\/wp-content\/uploads\/2025\/02\/faktoriyel_iteratif_vs_recursive-300x182.jpg 300w, http:\/\/www.cuneytbayrak.com\/wp-content\/uploads\/2025\/02\/faktoriyel_iteratif_vs_recursive-768x465.jpg 768w, http:\/\/www.cuneytbayrak.com\/wp-content\/uploads\/2025\/02\/faktoriyel_iteratif_vs_recursive-1536x931.jpg 1536w, http:\/\/www.cuneytbayrak.com\/wp-content\/uploads\/2025\/02\/faktoriyel_iteratif_vs_recursive-2048x1241.jpg 2048w\" sizes=\"auto, (max-width: 1024px) 100vw, 1024px\" \/><\/a><\/p>\n<p>Kolay gele&#8230;<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Fakt\u00f6riyel hesab\u0131n\u0131 iteratif ve recursive y\u00f6ntemle daha evvel yapm\u0131\u015ft\u0131k. \u0130lgili yaz\u0131lara ar\u015fivden ula\u015fabilirsiniz. Peki ama hangi y\u00f6ntem daha h\u0131zl\u0131 sonu\u00e7 veriyor buna bir bakal\u0131m. Her iki y\u00f6ntem i\u00e7in kulland\u0131\u011f\u0131m python&#8230;<\/p>\n<div class=\"more-link-wrapper\"><a class=\"more-link\" href=\"http:\/\/www.cuneytbayrak.com\/?p=131\">Devam\u0131n\u0131 Oku<span class=\"screen-reader-text\">Fakt\u00f6riyel Hesab\u0131nda \u0130teratif Y\u00f6ntem mi? Recursive Y\u00f6ntem mi?<\/span><\/a><\/div>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"iawp_total_views":0,"footnotes":""},"categories":[2],"tags":[37],"class_list":["post-131","post","type-post","status-publish","format-standard","hentry","category-algoritmalar","tag-factorialiterativevsrecursive","excerpt"],"_links":{"self":[{"href":"http:\/\/www.cuneytbayrak.com\/index.php?rest_route=\/wp\/v2\/posts\/131","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/www.cuneytbayrak.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.cuneytbayrak.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.cuneytbayrak.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.cuneytbayrak.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=131"}],"version-history":[{"count":2,"href":"http:\/\/www.cuneytbayrak.com\/index.php?rest_route=\/wp\/v2\/posts\/131\/revisions"}],"predecessor-version":[{"id":134,"href":"http:\/\/www.cuneytbayrak.com\/index.php?rest_route=\/wp\/v2\/posts\/131\/revisions\/134"}],"wp:attachment":[{"href":"http:\/\/www.cuneytbayrak.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=131"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.cuneytbayrak.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=131"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.cuneytbayrak.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=131"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}