{"id":7694,"date":"2026-08-01T00:02:58","date_gmt":"2026-08-01T07:02:58","guid":{"rendered":"https:\/\/c-for-dummies.com\/blog\/?p=7694"},"modified":"2026-08-01T11:30:51","modified_gmt":"2026-08-01T18:30:51","slug":"ramanujan-nested-radicals","status":"publish","type":"post","link":"https:\/\/c-for-dummies.com\/blog\/?p=7694","title":{"rendered":"Ramanujan Nested Radicals"},"content":{"rendered":"<h2>Difficulty: &#9733; &#9733; &#9733; &#9733;<\/h2>\n<p><a href=\"https:\/\/en.wikipedia.org\/wiki\/Srinivasa_Ramanujan\" target=\"_blank\">Srinivasa Ramanujan<\/a> was a mathematician of the genius variety in that he did amazing things in his short lifetime. The man was insanely brilliant. In fact, he struggled to get other mathematicians to understand his work because it was so unfamiliar. Anyway, he concocted the thing shown in Figure 1, which is one of many Ramanujan Nested Radicals:<br \/>\n<!--more--><br \/>\n<div id=\"attachment_7697\" style=\"width: 560px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-7697\" src=\"https:\/\/c-for-dummies.com\/blog\/wp-content\/uploads\/2026\/07\/08exercise-figure1.png\" alt=\"\" width=\"550\" height=\"61\" class=\"size-full wp-image-7697\" srcset=\"https:\/\/c-for-dummies.com\/blog\/wp-content\/uploads\/2026\/07\/08exercise-figure1.png 550w, https:\/\/c-for-dummies.com\/blog\/wp-content\/uploads\/2026\/07\/08exercise-figure1-300x33.png 300w, https:\/\/c-for-dummies.com\/blog\/wp-content\/uploads\/2026\/07\/08exercise-figure1-500x55.png 500w\" sizes=\"auto, (max-width: 550px) 100vw, 550px\" \/><p id=\"caption-attachment-7697\" class=\"wp-caption-text\">Figure 1. One of Ramanujan&#8217;s more famous nested radicals also called an infinite identity.<\/p><\/div><\/p>\n<p>A nested radical is a radial expression that contains another radical expression. A simple and more comprehensible example is shown in Figure 2.<\/p>\n<div id=\"attachment_7699\" style=\"width: 153px\" class=\"wp-caption aligncenter\"><img loading=\"lazy\" decoding=\"async\" aria-describedby=\"caption-attachment-7699\" src=\"https:\/\/c-for-dummies.com\/blog\/wp-content\/uploads\/2026\/08\/08exercise-figure2.png\" alt=\"\" width=\"143\" height=\"62\" class=\"size-full wp-image-7699\" \/><p id=\"caption-attachment-7699\" class=\"wp-caption-text\">Figure 2. A nested radical.<\/p><\/div>\n<p>The radical (square root) contains an expression with another radical (square root). But for Ramanujan, the insanity just kept going.<\/p>\n<p>From Figure 1, you see that the pattern is to add to 1 the square root of one plus two times the square root of one plus three, and so on to infinity.<\/p>\n<p>The delightful part is that the result of the nested radical operation is three. Yes, all that nonsense when calculated out to infinity results in the integer value 3.0.<\/p>\n<p>I hope you can appreciate the brilliance of Srinivasa Ramanujan because he was able to discern this type of contraption in his head and know its result without the aid of a computer.<\/p>\n<p>As a C programmer, you have a computer. And you have in your brain the ability to code the Ramanujan Nested Radical example shown in Figure 1 to prove that the result is 3.0. Yes, this calculation involves recursion. Well, I suppose you could probably muster the code to do calculate the value without recursion (which I&#8217;d love to see), but I used recursion for my solution. Here&#8217;s the output:<\/p>\n<pre>3.000000<\/pre>\n<p>Please try this exercise on your own before you peek at my solution, which I&#8217;ll publish in a week.<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Time to squeeze another math thing into a recursive function. <a href=\"https:\/\/c-for-dummies.com\/blog\/?p=7694\">Continue reading <span class=\"meta-nav\">&rarr;<\/span><\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[3],"tags":[],"class_list":["post-7694","post","type-post","status-publish","format-standard","hentry","category-exercise"],"_links":{"self":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7694","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=7694"}],"version-history":[{"count":7,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7694\/revisions"}],"predecessor-version":[{"id":7719,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=\/wp\/v2\/posts\/7694\/revisions\/7719"}],"wp:attachment":[{"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=7694"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=7694"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/c-for-dummies.com\/blog\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=7694"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}