{"id":12068,"date":"2021-05-22T11:11:16","date_gmt":"2021-05-22T05:41:16","guid":{"rendered":"http:\/\/www.pythonpool.com\/?p=12068"},"modified":"2021-06-14T15:08:33","modified_gmt":"2021-06-14T09:38:33","slug":"hailstone-sequence-python","status":"publish","type":"post","link":"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/","title":{"rendered":"All You Need to Know About Hailstone Sequence in Python"},"content":{"rendered":"\n<p>Lets us first understand what a sequence is in the hailstone sequence python. A sequence is an ordered series of numbers that follows a particular pattern. A sequence can be something as simple as a series of odd numbers. A hailstone sequence is a series of numbers that increase and decrease while following a pattern and eventually end when a repeating pattern is found. <\/p>\n\n\n\n<div id=\"ez-toc-container\" class=\"ez-toc-v2_0_74 counter-hierarchy ez-toc-counter ez-toc-transparent ez-toc-container-direction\">\n<div class=\"ez-toc-title-container\">\n<p class=\"ez-toc-title\" style=\"cursor:inherit\">Contents<\/p>\n<span class=\"ez-toc-title-toggle\"><a href=\"#\" class=\"ez-toc-pull-right ez-toc-btn ez-toc-btn-xs ez-toc-btn-default ez-toc-toggle\" aria-label=\"Toggle Table of Content\"><span class=\"ez-toc-js-icon-con\"><span class=\"\"><span class=\"eztoc-hide\" style=\"display:none;\">Toggle<\/span><span class=\"ez-toc-icon-toggle-span\"><svg style=\"fill: #990303;color:#990303\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" class=\"list-377408\" width=\"20px\" height=\"20px\" viewBox=\"0 0 24 24\" fill=\"none\"><path d=\"M6 6H4v2h2V6zm14 0H8v2h12V6zM4 11h2v2H4v-2zm16 0H8v2h12v-2zM4 16h2v2H4v-2zm16 0H8v2h12v-2z\" fill=\"currentColor\"><\/path><\/svg><svg style=\"fill: #990303;color:#990303\" class=\"arrow-unsorted-368013\" xmlns=\"http:\/\/www.w3.org\/2000\/svg\" width=\"10px\" height=\"10px\" viewBox=\"0 0 24 24\" version=\"1.2\" baseProfile=\"tiny\"><path d=\"M18.2 9.3l-6.2-6.3-6.2 6.3c-.2.2-.3.4-.3.7s.1.5.3.7c.2.2.4.3.7.3h11c.3 0 .5-.1.7-.3.2-.2.3-.5.3-.7s-.1-.5-.3-.7zM5.8 14.7l6.2 6.3 6.2-6.3c.2-.2.3-.5.3-.7s-.1-.5-.3-.7c-.2-.2-.4-.3-.7-.3h-11c-.3 0-.5.1-.7.3-.2.2-.3.5-.3.7s.1.5.3.7z\"\/><\/svg><\/span><\/span><\/span><\/a><\/span><\/div>\n<nav><ul class='ez-toc-list ez-toc-list-level-1 eztoc-toggle-hide-by-default' ><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-1\" href=\"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/#Introduction_to_Hailstone_Sequence\" >Introduction to Hailstone Sequence<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-2\" href=\"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/#Example_of_Hailstone_Sequence\" >Example of Hailstone Sequence<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-3\" href=\"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/#Computing_the_Sequence\" >Computing the Sequence<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-4\" href=\"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/#Without_Recursionwhile_loop\" >Without Recursion(while loop)<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-5\" href=\"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/#With_Recursion\" >With Recursion<\/a><\/li><li class='ez-toc-page-1 ez-toc-heading-level-2'><a class=\"ez-toc-link ez-toc-heading-6\" href=\"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/#FAQs\" >FAQ&#8217;s<\/a><\/li><\/ul><\/nav><\/div>\n<h2 class=\"wp-block-heading\" id=\"h-introduction-to-hailstone-sequence\"><span class=\"ez-toc-section\" id=\"Introduction_to_Hailstone_Sequence\"><\/span>Introduction to Hailstone Sequence<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p><strong>The Hailstone sequence is also known as The Collatz Conjecture. It was a problem proposed by mathematician L. Collatz. It is known as the hailstone sequence because the sequence resembles the pattern of formation of hailstones. Hailstones get blown up by the winds in the cloud, come down when they form ice pellets, and again get blown by the winds. Similarly, the sequence increases and decreases its value alternatively. Thus, according to the sequence, we may start with any whole number but will always end up with the sequence of 4, 2, 1. <\/strong><\/p>\n\n\n\n<p>We start with a given number, &#8216;N..&#8217; If the number N is even, we will divide it by 2. Otherwise, if N is odd, multiply N by 3 and add 1 to it (3*N + 1). Thus, irrespective of the number we start with, the sequence will never be infinite and always come to an end.  <\/p>\n\n\n\n<p>Let us understand the hailstone sequence by taking an example. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-example-of-hailstone-sequence\"><span class=\"ez-toc-section\" id=\"Example_of_Hailstone_Sequence\"><\/span>Example of Hailstone Sequence<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Let us taking N = <strong>5<\/strong>.                                                                                                                                                                                                   Since N is odd, We will perform (3*N + 1) = (3*5 + 1) = <strong>16<\/strong>                   <\/p>\n\n\n\n<p>Now, 16 is even, so we will divide it by 2 = 16\/2 = <strong>8<\/strong>. <\/p>\n\n\n\n<p>We will follow the same pattern for the entire series. <\/p>\n\n\n\n<p>8 is even, so 8\/2 = <strong>4<\/strong>                                                                                                                                                                        4 is even, so 4\/2 = <strong>2<\/strong>                                                                                                                                                                                               2 is even, so 2\/2 = <strong>1<\/strong>                                                                                                                                                                    1 is odd, so (3*1 + 2) = <strong>4<\/strong>. Now, here as you can see, the sequence is repeating itself. It generated 4 again. So the sequence stops here.<\/p>\n\n\n\n<p>Therefore, the sequence for N = 5 is <strong>5, 16, 8, 4, 2, 1<\/strong><\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p class=\"has-medium-font-size\">Let us take another example of N = <strong>6<\/strong><\/p>\n\n\n\n<p>6 is even, so 6\/2 = <strong>3  <\/strong>                                                                                                                                                    3 is odd, so (3*3 + 1) = <strong>10<\/strong>                                                                                                                                10 is even, so 10\/2 = <strong>5 <\/strong>                                                                                                                                                  5 is odd, so (3*5 + 1) =<strong> 16<\/strong>                                                                                                                                 16 is even, so 16\/2 = <strong>8<\/strong>                                                                                                                                       8 is even, so 8\/2 = <strong>4<\/strong>                                                                                                                                          4 is even, so 4\/2 = <strong>2<\/strong>                                                                                                                                                                 2 is even, so 2\/2 =<strong> 1 <\/strong>                                                                                                                                           1 is odd, so (3*1 + 1) = 4. <\/p>\n\n\n\n<p>The hailstone sequence for N = 6 is <strong>6, 3, 10, 5, 16, 8, 4, 2, 1<\/strong><\/p>\n\n\n\n<p>As seen, for n = 6 too, the sequence is ending with 4, 2, 1 and is finite. <\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-computing-the-sequence\"><span class=\"ez-toc-section\" id=\"Computing_the_Sequence\"><\/span>Computing the Sequence<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Let us write a program in python to calculate the hailstone sequence. We will try to implement it both, recursively and non-<a href=\"https:\/\/en.wikipedia.org\/wiki\/Recursion\" target=\"_blank\" rel=\"noreferrer noopener\">recursively<\/a>. The sequence would be generated by taking the initial number of the sequence from the user as an input. The output would be the hailstone sequence in python generated along with the number of steps taken to find the entire sequence.<\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-without-recursion-while-loop\"><span class=\"ez-toc-section\" id=\"Without_Recursionwhile_loop\"><\/span><strong>Without Recursion<\/strong>(while loop)<span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>First, we will define a function named hailstone().<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\ndef hailstone(n):\n  hailstone_list = &#x5B;]\n  hailstone_list.append(int(n))\n  while n != 1:\n    if n % 2 == 0:\n      n = n\/2\n      hailstone_list.append(int(n))\n    else:\n      n = 3*n + 1\n      hailstone_list.append(int(n))\n  return hailstone_list\n<\/pre><\/div>\n\n\n<p>It will accept one argument n &#8211; which is the beginning number of the sequence and will return a list. There will be a while loop that will stop the execution if n becomes 1. We have a list named <em>hailstone_list<\/em> which will store the sequence. If n is even, n would be divided by 2 else it will be multiplied by 3 and then 1 will be added to it. The numbers would be appended to the list.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nn = int(input(&quot;Enter n:&quot;))\nhailstone_list = &#x5B;]\nhailstone_list = hailstone(n)\nprint(&quot;Hailstone Sequence for n = {} is : {}&quot;.format(n, hailstone_list)) \nprint(&quot;Number of steps is : &quot;,len(hailstone_list))\n<\/pre><\/div>\n\n\n<p> Here, n would be taken as input from the user. We call hailstone function by passing n as the argument and store the return value inside an empty list hailstone_list. Then the print statements will print the hailstone sequence and the number of steps. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Enter n:7\n\nHailstone Sequence for n = 7 is : [7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1]\n\nNumber of steps is :  17<\/pre>\n\n\n\n<p>Here also the sequence has terminated with 4, 2, 1. <\/p>\n\n\n\n<p class=\"has-white-color has-text-color has-background has-medium-font-size\" style=\"background-color:#10c41c\">Also, Read | <a href=\"http:\/\/www.pythonpool.com\/collatz-sequence-python\/\" target=\"_blank\" rel=\"noreferrer noopener\"><span style=\"text-decoration: underline;\"><span class=\"has-inline-color has-black-color\">Understanding Collatz Sequence in Python<\/span><\/span><\/a><\/p>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-with-recursion\"><span class=\"ez-toc-section\" id=\"With_Recursion\"><\/span><strong>With Recursion<\/strong><span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<p>Now, we will be implementing the hailstone sequence in python with the help of recursion. If n is one, we will return the hailstone_list. If n is an even number, we shall call the hailstone() function by recursion and pass n\/2 as the argument. Else if n is an even number, we shall call hailstone() function by recursion but pass (3*n + 1) as the argument to the function.<\/p>\n\n\n<div class=\"wp-block-syntaxhighlighter-code \"><pre class=\"brush: python; title: ; notranslate\" title=\"\">\nhailstone_list = &#x5B;]\ndef hailstone(n):\n  hailstone_list.append(int(n))\n  if n == 1:\n    return hailstone_list\n  while n != 1:\n    if n % 2 == 0:\n      return hailstone(int(n\/2))\n    else:\n      return hailstone(int(3*n + 1))\n\nn = int(input(&quot;Enter n:&quot;))\nhailstone_list = &#x5B;]\nhailstone_list = hailstone(n)\nprint(&quot;Hailstone Sequence for n = {} is : {}&quot;.format(n, hailstone_list)) \nprint(&quot;Number of steps is : &quot;,len(hailstone_list))\n<\/pre><\/div>\n\n\n<p>The output for different values of n is:<\/p>\n\n\n\n<p><strong>N = 7:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Enter n:7\nHailstone Sequence for n = 7 is : [7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1]\nNumber of steps is :  17<\/pre>\n\n\n\n<p><strong>N = 6:<\/strong><\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Enter n:6\nHailstone Sequence for n = 6 is : [6, 3, 10, 5, 16, 8, 4, 2, 1]\nNumber of steps is :  9<\/pre>\n\n\n\n<p>Even for large values of n, the sequence shall always end with 1. <\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Enter n:19840\n\nHailstone Sequence for n = 19840 is : [19840, 9920, 4960, 2480, 1240, 620, 310, 155, 466, 233, 700, 350, 175, 526, 263, 790, 395, 1186, 593, 1780, 890, 445, 1336, 668, 334, 167, 502, 251, 754, 377, 1132, 566, 283, 850, 425, 1276, 638, 319, 958, 479, 1438, 719, 2158, 1079, 3238, 1619, 4858, 2429, 7288, 3644, 1822, 911, 2734, 1367, 4102, 2051, 6154, 3077, 9232, 4616, 2308, 1154, 577, 1732, 866, 433, 1300, 650, 325, 976, 488, 244, 122, 61, 184, 92, 46, 23, 70, 35, 106, 53, 160, 80, 40, 20, 10, 5, 16, 8, 4, 2, 1]\n\nNumber of steps is :  93<\/pre>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<h2 class=\"wp-block-heading\" id=\"h-faq-s\"><span class=\"ez-toc-section\" id=\"FAQs\"><\/span>FAQ&#8217;s <span class=\"ez-toc-section-end\"><\/span><\/h2>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-q-what-is-the-longest-hailstone-sequence\">Q. <strong>What is the longest hailstone sequence?<\/strong><\/h4>\n\n\n\n<p>A. The longest hailstone sequence is for the number 77031 whose length is 351.<\/p>\n\n\n\n<pre class=\"wp-block-preformatted\">Enter n:77031\n\nHailstone Sequence for n = 77031 is : [77031, 231094, 115547, 346642, 173321, 519964, 259982, 129991, 389974, 194987, 584962, 292481, 877444, 438722, 219361, 658084, 329042, 164521, 493564, 246782, 123391, 370174, 185087, 555262, 277631, 832894, 416447, 1249342, 624671, 1874014, 937007, 2811022, 1405511, 4216534, 2108267, 6324802, 3162401, 9487204, 4743602, 2371801, 7115404, 3557702, 1778851, 5336554, 2668277, 8004832, 4002416, 2001208, 1000604, 500302, 250151, 750454, 375227, 1125682, 562841, 1688524, 844262, 422131, 1266394, 633197, 1899592, 949796, 474898, 237449, 712348, 356174, 178087, 534262, 267131, 801394, 400697, 1202092, 601046, 300523, 901570, 450785, 1352356, 676178, 338089, 1014268, 507134, 253567, 760702, 380351, 1141054, 570527, 1711582, 855791, 2567374, 1283687, 3851062, 1925531, 5776594, 2888297, 8664892, 4332446, 2166223, 6498670, 3249335, 9748006, 4874003, 14622010, 7311005, 21933016, 10966508, 5483254, 2741627, 8224882, 4112441, 12337324, 6168662, 3084331, 9252994, 4626497, 13879492, 6939746, 3469873, 10409620, 5204810, 2602405, 7807216, 3903608, 1951804, 975902, 487951, 1463854, 731927, 2195782, 1097891, 3293674, 1646837, 4940512, 2470256, 1235128, 617564, 308782, 154391, 463174, 231587, 694762, 347381, 1042144, 521072, 260536, 130268, 65134, 32567, 97702, 48851, 146554, 73277, 219832, 109916, 54958, 27479, 82438, 41219, 123658, 61829, 185488, 92744, 46372, 23186, 11593, 34780, 17390, 8695, 26086, 13043, 39130, 19565, 58696, 29348, 14674, 7337, 22012, 11006, 5503, 16510, 8255, 24766, 12383, 37150, 18575, 55726, 27863, 83590, 41795, 125386, 62693, 188080, 94040, 47020, 23510, 11755, 35266, 17633, 52900, 26450, 13225, 39676, 19838, 9919, 29758, 14879, 44638, 22319, 66958, 33479, 100438, 50219, 150658, 75329, 225988, 112994, 56497, 169492, 84746, 42373, 127120, 63560, 31780, 15890, 7945, 23836, 11918, 5959, 17878, 8939, 26818, 13409, 40228, 20114, 10057, 30172, 15086, 7543, 22630, 11315, 33946, 16973, 50920, 25460, 12730, 6365, 19096, 9548, 4774, 2387, 7162, 3581, 10744, 5372, 2686, 1343, 4030, 2015, 6046, 3023, 9070, 4535, 13606, 6803, 20410, 10205, 30616, 15308, 7654, 3827, 11482, 5741, 17224, 8612, 4306, 2153, 6460, 3230, 1615, 4846, 2423, 7270, 3635, 10906, 5453, 16360, 8180, 4090, 2045, 6136, 3068, 1534, 767, 2302, 1151, 3454, 1727, 5182, 2591, 7774, 3887, 11662, 5831, 17494, 8747, 26242, 13121, 39364, 19682, 9841, 29524, 14762, 7381, 22144, 11072, 5536, 2768, 1384, 692, 346, 173, 520, 260, 130, 65, 196, 98, 49, 148, 74, 37, 112, 56, 28, 14, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1]\n\nNumber of steps is :  351<\/pre>\n\n\n\n<h4 class=\"wp-block-heading\" id=\"h-q-is-the-hailstone-sequence-solved\">Q. <strong>Is the hailstone sequence solved?<\/strong><\/h4>\n\n\n\n<p>A. Hailstone sequence has been checked for two to the sixtieth <a href=\"http:\/\/www.pythonpool.com\/numpy-power\/\" target=\"_blank\" rel=\"noreferrer noopener\">power<\/a> numbers (2^60). All the sequences generated up to that number has turned out to be a finite sequence ending with the same pattern &#8211; 4, 2, 1. <\/p>\n\n\n\n<hr class=\"wp-block-separator\"\/>\n\n\n\n<p>That was all about hailstone sequence in python. If you have any questions or thoughts to share, let us know in the comments.<\/p>\n\n\n\n<p><em>Till then, Happy Learning!<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>Lets us first understand what a sequence is in the hailstone sequence python. A sequence is an ordered series of numbers that follows a particular &#8230; <\/p>\n<p class=\"read-more-container\"><a title=\"All You Need to Know About Hailstone Sequence in Python\" class=\"read-more button\" href=\"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/#more-12068\" aria-label=\"More on All You Need to Know About Hailstone Sequence in Python\">Read more<\/a><\/p>\n","protected":false},"author":20,"featured_media":12201,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"_monsterinsights_sitenote_active":false,"_monsterinsights_sitenote_note":"","_monsterinsights_sitenote_category":0,"footnotes":""},"categories":[1654],"tags":[4061,4060,4062],"class_list":["post-12068","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-algorithm","tag-hailstone-sequence-recursion-python","tag-python-hailstone-sequence","tag-simple-hailstone-sequence-python-code","infinite-scroll-item"],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v20.1 (Yoast SEO v25.0) - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>All You Need to Know About Hailstone Sequence in Python - Python Pool<\/title>\n<meta name=\"description\" content=\"A hailstone sequence in python is a series of numbers are increasing and decreasing and eventually end when a repeating pattern is found.\" \/>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"All You Need to Know About Hailstone Sequence in Python\" \/>\n<meta property=\"og:description\" content=\"Lets us first understand what a sequence is in the hailstone sequence python. A sequence is an ordered series of numbers that follows a particular\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/\" \/>\n<meta property=\"og:site_name\" content=\"Python Pool\" \/>\n<meta property=\"article:published_time\" content=\"2021-05-22T05:41:16+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-06-14T09:38:33+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/05\/All-You-Need-to-Know-About-Hailstone-Sequence-in-Python.png\" \/>\n\t<meta property=\"og:image:width\" content=\"1350\" \/>\n\t<meta property=\"og:image:height\" content=\"650\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/png\" \/>\n<meta name=\"author\" content=\"Dhruvi Vikma\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:creator\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:site\" content=\"@pythonpool\" \/>\n<meta name=\"twitter:label1\" content=\"Written by\" \/>\n\t<meta name=\"twitter:data1\" content=\"Dhruvi Vikma\" \/>\n\t<meta name=\"twitter:label2\" content=\"Est. reading time\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 minutes\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/\"},\"author\":{\"name\":\"Dhruvi Vikma\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/bed8fc40c7b71baf7d76b1cfefd79f23\"},\"headline\":\"All You Need to Know About Hailstone Sequence in Python\",\"datePublished\":\"2021-05-22T05:41:16+00:00\",\"dateModified\":\"2021-06-14T09:38:33+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/\"},\"wordCount\":748,\"commentCount\":2,\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/05\/All-You-Need-to-Know-About-Hailstone-Sequence-in-Python.png\",\"keywords\":[\"hailstone sequence recursion python\",\"python hailstone sequence\",\"simple hailstone sequence python code\"],\"articleSection\":[\"Algorithm\"],\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/\",\"url\":\"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/\",\"name\":\"All You Need to Know About Hailstone Sequence in Python - Python Pool\",\"isPartOf\":{\"@id\":\"https:\/\/www.pythonpool.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/#primaryimage\"},\"thumbnailUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/05\/All-You-Need-to-Know-About-Hailstone-Sequence-in-Python.png\",\"datePublished\":\"2021-05-22T05:41:16+00:00\",\"dateModified\":\"2021-06-14T09:38:33+00:00\",\"description\":\"A hailstone sequence in python is a series of numbers are increasing and decreasing and eventually end when a repeating pattern is found.\",\"breadcrumb\":{\"@id\":\"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/#primaryimage\",\"url\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/05\/All-You-Need-to-Know-About-Hailstone-Sequence-in-Python.png\",\"contentUrl\":\"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/05\/All-You-Need-to-Know-About-Hailstone-Sequence-in-Python.png\",\"width\":1350,\"height\":650,\"caption\":\"hailstone sequence python\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\/\/www.pythonpool.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"All You Need to Know About Hailstone Sequence in Python\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.pythonpool.com\/#website\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"name\":\"Python Pool\",\"description\":\"Your One-Stop Python Learning Destination\",\"publisher\":{\"@id\":\"https:\/\/www.pythonpool.com\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.pythonpool.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"en-US\"},{\"@type\":\"Organization\",\"@id\":\"https:\/\/www.pythonpool.com\/#organization\",\"name\":\"Python Pool\",\"url\":\"https:\/\/www.pythonpool.com\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\",\"url\":\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"contentUrl\":\"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png\",\"width\":452,\"height\":185,\"caption\":\"Python Pool\"},\"image\":{\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/\"},\"sameAs\":[\"https:\/\/x.com\/pythonpool\",\"https:\/\/www.youtube.com\/c\/pythonpool\"]},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/bed8fc40c7b71baf7d76b1cfefd79f23\",\"name\":\"Dhruvi Vikma\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"en-US\",\"@id\":\"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/secure.gravatar.com\/avatar\/520d8a37e8b6ce4e6df57e997dc0d571225f48098bbb02838c3884bb603e886f?s=96&d=wavatar&r=g\",\"contentUrl\":\"https:\/\/secure.gravatar.com\/avatar\/520d8a37e8b6ce4e6df57e997dc0d571225f48098bbb02838c3884bb603e886f?s=96&d=wavatar&r=g\",\"caption\":\"Dhruvi Vikma\"}}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","yoast_head_json":{"title":"All You Need to Know About Hailstone Sequence in Python - Python Pool","description":"A hailstone sequence in python is a series of numbers are increasing and decreasing and eventually end when a repeating pattern is found.","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/","og_locale":"en_US","og_type":"article","og_title":"All You Need to Know About Hailstone Sequence in Python","og_description":"Lets us first understand what a sequence is in the hailstone sequence python. A sequence is an ordered series of numbers that follows a particular","og_url":"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/","og_site_name":"Python Pool","article_published_time":"2021-05-22T05:41:16+00:00","article_modified_time":"2021-06-14T09:38:33+00:00","og_image":[{"width":1350,"height":650,"url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/05\/All-You-Need-to-Know-About-Hailstone-Sequence-in-Python.png","type":"image\/png"}],"author":"Dhruvi Vikma","twitter_card":"summary_large_image","twitter_creator":"@pythonpool","twitter_site":"@pythonpool","twitter_misc":{"Written by":"Dhruvi Vikma","Est. reading time":"5 minutes"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/#article","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/"},"author":{"name":"Dhruvi Vikma","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/bed8fc40c7b71baf7d76b1cfefd79f23"},"headline":"All You Need to Know About Hailstone Sequence in Python","datePublished":"2021-05-22T05:41:16+00:00","dateModified":"2021-06-14T09:38:33+00:00","mainEntityOfPage":{"@id":"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/"},"wordCount":748,"commentCount":2,"publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"image":{"@id":"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/05\/All-You-Need-to-Know-About-Hailstone-Sequence-in-Python.png","keywords":["hailstone sequence recursion python","python hailstone sequence","simple hailstone sequence python code"],"articleSection":["Algorithm"],"inLanguage":"en-US","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.pythonpool.com\/hailstone-sequence-python\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/","url":"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/","name":"All You Need to Know About Hailstone Sequence in Python - Python Pool","isPartOf":{"@id":"https:\/\/www.pythonpool.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/#primaryimage"},"image":{"@id":"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/#primaryimage"},"thumbnailUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/05\/All-You-Need-to-Know-About-Hailstone-Sequence-in-Python.png","datePublished":"2021-05-22T05:41:16+00:00","dateModified":"2021-06-14T09:38:33+00:00","description":"A hailstone sequence in python is a series of numbers are increasing and decreasing and eventually end when a repeating pattern is found.","breadcrumb":{"@id":"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/#breadcrumb"},"inLanguage":"en-US","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.pythonpool.com\/hailstone-sequence-python\/"]}]},{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/#primaryimage","url":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/05\/All-You-Need-to-Know-About-Hailstone-Sequence-in-Python.png","contentUrl":"https:\/\/www.pythonpool.com\/wp-content\/uploads\/2021\/05\/All-You-Need-to-Know-About-Hailstone-Sequence-in-Python.png","width":1350,"height":650,"caption":"hailstone sequence python"},{"@type":"BreadcrumbList","@id":"https:\/\/www.pythonpool.com\/hailstone-sequence-python\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.pythonpool.com\/"},{"@type":"ListItem","position":2,"name":"All You Need to Know About Hailstone Sequence in Python"}]},{"@type":"WebSite","@id":"https:\/\/www.pythonpool.com\/#website","url":"https:\/\/www.pythonpool.com\/","name":"Python Pool","description":"Your One-Stop Python Learning Destination","publisher":{"@id":"https:\/\/www.pythonpool.com\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.pythonpool.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"en-US"},{"@type":"Organization","@id":"https:\/\/www.pythonpool.com\/#organization","name":"Python Pool","url":"https:\/\/www.pythonpool.com\/","logo":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/","url":"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","contentUrl":"http:\/\/www.pythonpool.com\/wp-content\/uploads\/2020\/08\/aa.png","width":452,"height":185,"caption":"Python Pool"},"image":{"@id":"https:\/\/www.pythonpool.com\/#\/schema\/logo\/image\/"},"sameAs":["https:\/\/x.com\/pythonpool","https:\/\/www.youtube.com\/c\/pythonpool"]},{"@type":"Person","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/bed8fc40c7b71baf7d76b1cfefd79f23","name":"Dhruvi Vikma","image":{"@type":"ImageObject","inLanguage":"en-US","@id":"https:\/\/www.pythonpool.com\/#\/schema\/person\/image\/","url":"https:\/\/secure.gravatar.com\/avatar\/520d8a37e8b6ce4e6df57e997dc0d571225f48098bbb02838c3884bb603e886f?s=96&d=wavatar&r=g","contentUrl":"https:\/\/secure.gravatar.com\/avatar\/520d8a37e8b6ce4e6df57e997dc0d571225f48098bbb02838c3884bb603e886f?s=96&d=wavatar&r=g","caption":"Dhruvi Vikma"}}]}},"_links":{"self":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/12068","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/users\/20"}],"replies":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/comments?post=12068"}],"version-history":[{"count":28,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/12068\/revisions"}],"predecessor-version":[{"id":13506,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/posts\/12068\/revisions\/13506"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media\/12201"}],"wp:attachment":[{"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/media?parent=12068"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/categories?post=12068"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.pythonpool.com\/wp-json\/wp\/v2\/tags?post=12068"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}