diff --git a/.vscode/settings.json b/.vscode/settings.json index 7c6d168..c07c0bf 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,16 @@ { - "cSpell.words": [ - "venkat" - ] -} \ No newline at end of file + "cSpell.words": ["venkat"], + + // The number of spaces a tab is equal to. This setting is overridden + // based on the file contents when `editor.detectIndentation` is true. + "editor.tabSize": 2, + + // Insert spaces when pressing Tab. This setting is overriden + // based on the file contents when `editor.detectIndentation` is true. + "editor.insertSpaces": true, + + // When opening a file, `editor.tabSize` and `editor.insertSpaces` + // will be detected based on the file contents. Set to false to keep + // the values you've explicitly set, above. + "editor.detectIndentation": false +} diff --git a/docs/404.html b/docs/404.html index 473e5c9..a7b14ba 100644 --- a/docs/404.html +++ b/docs/404.html @@ -1 +1 @@ -404: This page could not be found

404

This page could not be found.

\ No newline at end of file +404: This page could not be found

404

This page could not be found.

\ No newline at end of file diff --git a/docs/_next/static/chunks/470-dc823fbb15afc6f0245e.js b/docs/_next/static/chunks/470-dc823fbb15afc6f0245e.js new file mode 100644 index 0000000..b3d27f7 --- /dev/null +++ b/docs/_next/static/chunks/470-dc823fbb15afc6f0245e.js @@ -0,0 +1 @@ +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[470],{7610:function(t,e,n){"use strict";n.d(e,{F:function(){return l}});var r=n(5893),a=n(5988),i=n(1664),l=function(t){var e=t.meta,n=t.link,l=t.isBlogPost;return(0,r.jsxs)(r.Fragment,{children:[l?(0,r.jsx)("h1",{className:"jsx-4001257583 "+((l?"great-title":null)||""),children:e.title}):(0,r.jsx)(i.default,{href:n,children:(0,r.jsx)("h1",{className:"jsx-4001257583 "+((l?"great-title":null)||""),children:e.title})}),(0,r.jsxs)("div",{className:"jsx-4001257583 details",children:[l?null:(0,r.jsx)("p",{className:"jsx-4001257583",children:e.description}),(0,r.jsx)("span",{className:"jsx-4001257583",children:e.date}),(0,r.jsxs)("span",{role:"img","aria-label":"one coffee",className:"jsx-4001257583",children:["\u2615 ",e.readTime+" mins read"]})]}),(0,r.jsx)(a.default,{id:"4001257583",children:["h1.jsx-4001257583{font-size:1.5rem;font-weight:700;color:#f39c12;}",".great-title.jsx-4001257583{font-size:2rem;}",".details.jsx-4001257583 span.jsx-4001257583{color:#bdbdbd;margin-right:1rem;}",".details.jsx-4001257583{margin-bottom:1rem;}"]})]})}},2477:function(t,e,n){"use strict";var r=n(5893),a=n(9008),i=n(5962),l=n(1930);e.Z=function(t){var e=t.title;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(a.default,{children:[(0,r.jsx)("title",{children:e}),(0,r.jsx)("meta",{name:"viewport",content:"initial-scale=1.0, width=device-width"})]}),(0,r.jsx)(l.Z,{}),(0,r.jsx)(i.Z,{})]})}},2052:function(t,e,n){"use strict";n.d(e,{Z:function(){return l}});var r=n(5893),a=n(7610),i=n(2477);function l(t){var e=t.children,n=t.meta;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Z,{title:n.title}),(0,r.jsx)(a.F,{meta:n,isBlogPost:!0}),(0,r.jsx)("article",{children:e})]})}},1930:function(t,e,n){"use strict";var r=n(5893),a=n(1664);e.Z=function(t){var e=t.type,n=void 0===e?"header-logo":e;return n?(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(a.default,{href:"/",className:"link",children:(0,r.jsx)("img",{src:"/images/webslate.jpg",alt:"Web Slate.io",className:n})})}):(0,r.jsx)("img",{src:"images/webslate.jpg",alt:"Web Slate.io"})}},5962:function(t,e,n){"use strict";var r=n(5893);e.Z=function(){return(0,r.jsxs)("p",{children:[(0,r.jsx)("a",{href:"/",children:"Home"})," | ",(0,r.jsx)("a",{href:"/blogs/js",children:"JavaScript"})," |"," ",(0,r.jsx)("a",{href:"/blogs/html",children:"HTML5"})," | ",(0,r.jsx)("a",{href:"/blogs/react",children:"React"})," |"," ",(0,r.jsx)("a",{href:"/blogs/programming",children:"Programming"})," | ",(0,r.jsx)("a",{href:"/blogs/problems",children:"Problems"})," |"," ",(0,r.jsx)("a",{href:"/about",children:"About"})]})}},8470:function(t,e,n){"use strict";n.r(e),n.d(e,{default:function(){return E},meta:function(){return C}});var r=n(6156),a=n(7375),i=n(7294),l=n(4137),o=n(2052),s=n(5893),c=n(2465),p=n(9163);function m(){var t=(0,c.Z)(["\n display: table-cell;\n"]);return m=function(){return t},t}function u(){var t=(0,c.Z)(["\n display: table-cell;\n text-align: right;\n padding-right: 1em;\n user-select: none;\n opacity: 0.5;\n"]);return u=function(){return t},t}function h(){var t=(0,c.Z)(["\n display: table-row;\n"]);return h=function(){return t},t}function k(){var t=(0,c.Z)(["\n text-align: left;\n margin: 1em 0;\n padding: 0.5em;\n overflow: scroll;\n\n & .token-line {\n line-height: 1.3em;\n height: 1.3em;\n }\n"]);return k=function(){return t},t}function d(){var t=(0,c.Z)(["\n font-family: sans-serif;\n text-align: center;\n"]);return d=function(){return t},t}var g=p.ZP.div(d()),f=p.ZP.pre(k()),b=p.ZP.div(h()),N=p.ZP.span(u()),y=p.ZP.span(m()),x=n(9235),w=n(5424);function v(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function j(t){for(var e=1;e=0, GCD(F",(0,l.kt)("sub",null,"n"),", F",(0,l.kt)("sub",null,"n+1"),") = 1"),(0,l.kt)("li",{parentName:"ol"},"For n>=0, GCD(F",(0,l.kt)("sub",null,"n"),", F",(0,l.kt)("sub",null,"n+2"),") = 1"),(0,l.kt)("li",{parentName:"ol"},"Sum of any six consecutive fibonacci numbers is divisible by 4"),(0,l.kt)("li",{parentName:"ol"},"Sum of 10 consecutive fibonacci numbers is divisible by 11"),(0,l.kt)("li",{parentName:"ol"},"and there is five more properties until 9.")),(0,l.kt)("h2",null,(0,l.kt)("a",{name:"solutions"},"Solutions")),(0,l.kt)("p",null,"There is various kinds of approaches in order to get this sequence and there is many solutions available. lets see each of them with solutions written in javascript.\nBefore, lets look at the formulae."),(0,l.kt)("ol",null,(0,l.kt)("li",{parentName:"ol"},"F",(0,l.kt)("sub",null,"0")," = 0, F",(0,l.kt)("sub",null,"1")," = 1 (initial conditions)"),(0,l.kt)("li",{parentName:"ol"},"Fn = F",(0,l.kt)("sub",null,"n-1")," + F",(0,l.kt)("sub",null,"n-2"),", n>=2 (Recurrence Relation)")),(0,l.kt)("h3",null,"1. ",(0,l.kt)("a",{name:"properties"},"Recursive Approach")),(0,l.kt)("p",null,"Basically, this approach call itself creating more and more branches of the tree until it hits the base case.\nBelow is the recursive solution in Javascript."),(0,l.kt)("p",null,(0,l.kt)("strong",{parentName:"p"},"Time Complexity:")," 2^n (exponential time)",(0,l.kt)("br",{parentName:"p"}),"\n",(0,l.kt)("strong",{parentName:"p"},"Space Complexity:")," O(n) considering function call stack size, otherwise O(1)."),(0,l.kt)(F,{mdxType:"CodeBlock"},"\nfunction fib_1(n) {\n if (n < 2) {\n return n\n }\n return fib_1(n - 1) + fib_1(n - 2)\n}\n".trim()),(0,l.kt)("h3",null,"2. ",(0,l.kt)("a",{name:"dynamic-programming"},"Dynamic Programming")),(0,l.kt)("ol",null,(0,l.kt)("li",{parentName:"ol"},"Dynamic Programming is mainly an optimization over plain recursion. Wherever we see a recursive solution that has repeated calls for same inputs, we can optimize it using Dynamic Programming. "),(0,l.kt)("li",{parentName:"ol"},"The idea is to simply store the results of sub problems to prevent re-computations of same inputs."),(0,l.kt)("li",{parentName:"ol"},"This helps to reduces time complexities from exponential to polynomial.")),(0,l.kt)("p",null,(0,l.kt)("strong",{parentName:"p"},"Time Complexity:")," O(n)\n",(0,l.kt)("strong",{parentName:"p"},"Space Complexity:")," O(1)"),(0,l.kt)(F,{mdxType:"CodeBlock"},"\nfunction fib_2(n) {\n let a = 0, b = 1, c, i;\n if (n == 0)\n return a;\n for (i = 2; i <= n; i++) {\n c = a + b;\n a = b;\n b = c;\n }\n return b;\n}\n".trim()),(0,l.kt)("h3",null,"3. ",(0,l.kt)("a",{name:"power-of-matrix-approach"},"Power of Matrix Approach")),(0,l.kt)("p",null,(0,l.kt)("strong",{parentName:"p"},"Time Complexity:")," O(Logn)\n",(0,l.kt)("strong",{parentName:"p"},"Space Complexity:")," O(1) or O(Logn) on function call stack size consideration."),(0,l.kt)(F,{mdxType:"CodeBlock"},"\nfunction fib(n) {\n const F = [[1, 1], [1, 0]];\n if (n == 0)\n return 0;\n power(F, n - 1);\n return F[0][0];\n}\n// Helper function that multiplies 2\n// matrices F and M of size 2*2, and\n// puts the multiplication result\n// back to F[][]\nfunction multiply(F, M) {\n const x = F[0][0] * M[0][0] + F[0][1] * M[1][0];\n const y = F[0][0] * M[0][1] + F[0][1] * M[1][1];\n const z = F[1][0] * M[0][0] + F[1][1] * M[1][0];\n const w = F[1][0] * M[0][1] + F[1][1] * M[1][1];\n F[0][0] = x;\n F[0][1] = y;\n F[1][0] = z;\n F[1][1] = w;\n}\n// Helper function that calculates F[][]\n// raise to the power n and puts the\n// result in F[][]\nfunction power(F, n) {\n const M = [[1, 1], [1, 0]];\n // n - 1 times multiply the\n // matrix to {{1,0},{0,1}}\n for (let i = 2; i <= n; i++)\n multiply(F, M);\n}\n// Optimized version of power() in method 4 */\nfunction power(F, n) {\n if (n == 0 || n == 1)\n return;\n const M = [[1, 1], [1, 0]];\n power(F, n / 2);\n multiply(F, F);\n if (n % 2 != 0)\n multiply(F, M);\n}\n".trim()),(0,l.kt)("h3",null,"4 ",(0,l.kt)("a",{name:"using-binets-formula"},"Using Binet's Formula")),(0,l.kt)("p",null,"Binet formula, sums, combinatorial representations and generating function of the generalized Fibonacci -numbers."),(0,l.kt)("p",null,(0,l.kt)("strong",{parentName:"p"},"Time Complexity:")," O(logn), this is because calculating phi^n takes logn time.",(0,l.kt)("br",{parentName:"p"}),"\n",(0,l.kt)("strong",{parentName:"p"},"Space Complexity:")," O(1)"),(0,l.kt)(F,{mdxType:"CodeBlock"},"\nfunction fib_4(n) {\n let phi = (1 + Math.sqrt(5)) / 2;\n return Math.round(Math.pow(phi, n) / Math.sqrt(5));\n}\n".trim()),(0,l.kt)("h2",null,(0,l.kt)("a",{name:"other-facts"},"Other Facts")),(0,l.kt)("p",null,"Let's look at the other facts where we used in real life."),(0,l.kt)("h3",null,(0,l.kt)("a",{name:"planets-activity"},"Planets Activity")),(0,l.kt)("p",null,"Even our planet activities like Rotations period, Precession Period, Orbital Period are in fibonacci. Refer to Journal of Astronomy on ",(0,l.kt)(T,{url:"http://article.sapub.org/10.5923.j.astronomy.20190801.02.html",mdxType:"ExternalLink"},"Modeling Celestial Mechanics Using the Fibonacci Numbers")),(0,l.kt)("h3",null,(0,l.kt)("a",{name:"golden-ratio"},"Golden Ratio (Phi)")),(0,l.kt)("p",null,"In mathematics, two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities where F",(0,l.kt)("sub",null,"(n+1)")," / F",(0,l.kt)("sub",null,"n")," is most of the time is 1.618"),(0,l.kt)("p",null,"Golden ratio everywhere like example below."),(0,l.kt)("ol",null,(0,l.kt)("li",{parentName:"ol"},"Flower petals"),(0,l.kt)("li",{parentName:"ol"},"Spiral of Pine Cone, Pineapple"),(0,l.kt)("li",{parentName:"ol"},"Storms spin in golden sequence"),(0,l.kt)("li",{parentName:"ol"},"Wave can be measured in this ratio."),(0,l.kt)("li",{parentName:"ol"},"Planet alignment and spirals of our Milky way galaxy"),(0,l.kt)("li",{parentName:"ol"},"Shoulder to elbow and elbow to fingertips will be 1:1.6"),(0,l.kt)("li",{parentName:"ol"},"Finger tips to wrist and wrist to elbow"),(0,l.kt)("li",{parentName:"ol"},"bottom of fingertips to wrist"),(0,l.kt)("li",{parentName:"ol"},"Even your ears, brains, lungs system even helix of our DNA that forms rhythm of our hearbeat."),(0,l.kt)("li",{parentName:"ol"},"Musical scales like piano.")),(0,l.kt)("h3",null,(0,l.kt)("a",{name:"fibonacci-extension"},"Fibonacci Extension")))}E.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/470-f0ae4cd03ec11b4cd584.js b/docs/_next/static/chunks/470-f0ae4cd03ec11b4cd584.js deleted file mode 100644 index 28e0a4d..0000000 --- a/docs/_next/static/chunks/470-f0ae4cd03ec11b4cd584.js +++ /dev/null @@ -1 +0,0 @@ -(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[470],{7610:function(t,e,n){"use strict";n.d(e,{F:function(){return l}});var r=n(5893),a=n(5988),i=n(1664),l=function(t){var e=t.meta,n=t.link,l=t.isBlogPost;return(0,r.jsxs)(r.Fragment,{children:[l?(0,r.jsx)("h1",{className:"jsx-4001257583 "+((l?"great-title":null)||""),children:e.title}):(0,r.jsx)(i.default,{href:n,children:(0,r.jsx)("h1",{className:"jsx-4001257583 "+((l?"great-title":null)||""),children:e.title})}),(0,r.jsxs)("div",{className:"jsx-4001257583 details",children:[l?null:(0,r.jsx)("p",{className:"jsx-4001257583",children:e.description}),(0,r.jsx)("span",{className:"jsx-4001257583",children:e.date}),(0,r.jsxs)("span",{role:"img","aria-label":"one coffee",className:"jsx-4001257583",children:["\u2615 ",e.readTime+" min read"]})]}),(0,r.jsx)(a.default,{id:"4001257583",children:["h1.jsx-4001257583{font-size:1.5rem;font-weight:700;color:#f39c12;}",".great-title.jsx-4001257583{font-size:2rem;}",".details.jsx-4001257583 span.jsx-4001257583{color:#bdbdbd;margin-right:1rem;}",".details.jsx-4001257583{margin-bottom:1rem;}"]})]})}},2477:function(t,e,n){"use strict";var r=n(5893),a=n(9008),i=n(5962),l=n(1930);e.Z=function(t){var e=t.title;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsxs)(a.default,{children:[(0,r.jsx)("title",{children:e}),(0,r.jsx)("meta",{name:"viewport",content:"initial-scale=1.0, width=device-width"})]}),(0,r.jsx)(l.Z,{}),(0,r.jsx)(i.Z,{})]})}},2052:function(t,e,n){"use strict";n.d(e,{Z:function(){return l}});var r=n(5893),a=n(7610),i=n(2477);function l(t){var e=t.children,n=t.meta;return(0,r.jsxs)(r.Fragment,{children:[(0,r.jsx)(i.Z,{title:n.title}),(0,r.jsx)(a.F,{meta:n,isBlogPost:!0}),(0,r.jsx)("article",{children:e})]})}},1930:function(t,e,n){"use strict";var r=n(5893),a=n(1664);e.Z=function(t){var e=t.type,n=void 0===e?"header-logo":e;return n?(0,r.jsx)(r.Fragment,{children:(0,r.jsx)(a.default,{href:"/",className:"link",children:(0,r.jsx)("img",{src:"/images/webslate.jpg",alt:"Web Slate.io",className:n})})}):(0,r.jsx)("img",{src:"images/webslate.jpg",alt:"Web Slate.io"})}},5962:function(t,e,n){"use strict";var r=n(5893);e.Z=function(){return(0,r.jsxs)("p",{children:[(0,r.jsx)("a",{href:"/",children:"Home"})," | ",(0,r.jsx)("a",{href:"/blogs/js",children:"JavaScript"})," |"," ",(0,r.jsx)("a",{href:"/blogs/html",children:"HTML5"})," | ",(0,r.jsx)("a",{href:"/blogs/react",children:"React"})," |"," ",(0,r.jsx)("a",{href:"/blogs/programming",children:"Programming"})," | ",(0,r.jsx)("a",{href:"/blogs/problems",children:"Problems"})," |"," ",(0,r.jsx)("a",{href:"/about",children:"About"})]})}},8470:function(t,e,n){"use strict";n.r(e),n.d(e,{default:function(){return Z},meta:function(){return M}});var r=n(6156),a=n(7375),i=(n(7294),n(4137)),l=n(2052),o=n(5893),s=n(2465),p=n(9163);function m(){var t=(0,s.Z)(["\n display: table-cell;\n"]);return m=function(){return t},t}function c(){var t=(0,s.Z)(["\n display: table-cell;\n text-align: right;\n padding-right: 1em;\n user-select: none;\n opacity: 0.5;\n"]);return c=function(){return t},t}function u(){var t=(0,s.Z)(["\n display: table-row;\n"]);return u=function(){return t},t}function h(){var t=(0,s.Z)(["\n text-align: left;\n margin: 1em 0;\n padding: 0.5em;\n overflow: scroll;\n\n & .token-line {\n line-height: 1.3em;\n height: 1.3em;\n }\n"]);return h=function(){return t},t}function d(){var t=(0,s.Z)(["\n font-family: sans-serif;\n text-align: center;\n"]);return d=function(){return t},t}var k=p.ZP.div(d()),g=p.ZP.pre(h()),f=p.ZP.div(u()),b=p.ZP.span(c()),N=p.ZP.span(m()),y=n(9235),x=n(5424);function w(t,e){var n=Object.keys(t);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(t);e&&(r=r.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.push.apply(n,r)}return n}function j(t){for(var e=1;e=0, GCD(F",(0,i.kt)("sub",null,"n"),", F",(0,i.kt)("sub",null,"n+1"),") = 1"),(0,i.kt)("li",{parentName:"ol"},"For n>=0, GCD(F",(0,i.kt)("sub",null,"n"),", F",(0,i.kt)("sub",null,"n+2"),") = 1"),(0,i.kt)("li",{parentName:"ol"},"Sum of any six consecutive fibonacci numbers is divisible by 4"),(0,i.kt)("li",{parentName:"ol"},"Sum of 10 consecutive fibonacci numbers is divisible by 11"),(0,i.kt)("li",{parentName:"ol"},"and there is five more properties until 9.")),(0,i.kt)("h2",null,(0,i.kt)("a",{name:"solutions"},"Solutions")),(0,i.kt)("p",null,"There is various kinds of approaches in order to get this sequence and there is many solutions available. lets see each of them with solutions written in javascript.\nBefore, lets look at the formulae."),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},"F",(0,i.kt)("sub",null,"0")," = 0, F",(0,i.kt)("sub",null,"1")," = 1 (initial conditions)"),(0,i.kt)("li",{parentName:"ol"},"Fn = F",(0,i.kt)("sub",null,"n-1")," + F",(0,i.kt)("sub",null,"n-2"),", n>=2 (Recurrence Relation)")),(0,i.kt)("h3",null,"1. ",(0,i.kt)("a",{name:"properties"},"Recursive Approach")),(0,i.kt)("p",null,"Basically, this approach call itself creating more and more branches of the tree until it hits the base case.\nBelow is the recursive solution in Javascript."),(0,i.kt)("p",null,(0,i.kt)("strong",{parentName:"p"},"Time Complexity:")," 2^n (exponential time)",(0,i.kt)("br",{parentName:"p"}),"\n",(0,i.kt)("strong",{parentName:"p"},"Space Complexity:")," O(n) considering function call stack size, otherwise O(1)."),(0,i.kt)(v,{mdxType:"CodeBlock"},"\nfunction fib_1(n) {\n if (n < 2) {\n return n\n }\n return fib_1(n - 1) + fib_1(n - 2)\n}\n".trim()),(0,i.kt)("h3",null,"2. ",(0,i.kt)("a",{name:"dynamic-programming"},"Dynamic Programming")),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},"Dynamic Programming is mainly an optimization over plain recursion. Wherever we see a recursive solution that has repeated calls for same inputs, we can optimize it using Dynamic Programming. "),(0,i.kt)("li",{parentName:"ol"},"The idea is to simply store the results of sub problems to prevent re-computations of same inputs."),(0,i.kt)("li",{parentName:"ol"},"This helps to reduces time complexities from exponential to polynomial.")),(0,i.kt)("p",null,(0,i.kt)("strong",{parentName:"p"},"Time Complexity:")," O(n)\n",(0,i.kt)("strong",{parentName:"p"},"Space Complexity:")," O(1)"),(0,i.kt)(v,{mdxType:"CodeBlock"},"\nfunction fib_2(n) {\n let a = 0, b = 1, c, i;\n if (n == 0)\n return a;\n for (i = 2; i <= n; i++) {\n c = a + b;\n a = b;\n b = c;\n }\n return b;\n}\n".trim()),(0,i.kt)("h3",null,"3. ",(0,i.kt)("a",{name:"power-of-matrix-approach"},"Power of Matrix Approach")),(0,i.kt)("p",null,(0,i.kt)("strong",{parentName:"p"},"Time Complexity:")," O(Logn)\n",(0,i.kt)("strong",{parentName:"p"},"Space Complexity:")," O(1) or O(Logn) on function call stack size consideration."),(0,i.kt)(v,{mdxType:"CodeBlock"},"\nfunction fib(n) {\n const F = [[1, 1], [1, 0]];\n if (n == 0)\n return 0;\n power(F, n - 1);\n return F[0][0];\n}\n// Helper function that multiplies 2\n// matrices F and M of size 2*2, and\n// puts the multiplication result\n// back to F[][]\nfunction multiply(F, M) {\n const x = F[0][0] * M[0][0] + F[0][1] * M[1][0];\n const y = F[0][0] * M[0][1] + F[0][1] * M[1][1];\n const z = F[1][0] * M[0][0] + F[1][1] * M[1][0];\n const w = F[1][0] * M[0][1] + F[1][1] * M[1][1];\n F[0][0] = x;\n F[0][1] = y;\n F[1][0] = z;\n F[1][1] = w;\n}\n// Helper function that calculates F[][]\n// raise to the power n and puts the\n// result in F[][]\nfunction power(F, n) {\n const M = [[1, 1], [1, 0]];\n // n - 1 times multiply the\n // matrix to {{1,0},{0,1}}\n for (let i = 2; i <= n; i++)\n multiply(F, M);\n}\n// Optimized version of power() in method 4 */\nfunction power(F, n) {\n if (n == 0 || n == 1)\n return;\n const M = [[1, 1], [1, 0]];\n power(F, n / 2);\n multiply(F, F);\n if (n % 2 != 0)\n multiply(F, M);\n}\n".trim()),(0,i.kt)("h3",null,"4 ",(0,i.kt)("a",{name:"using-binets-formula"},"Using Binet's Formula")),(0,i.kt)("p",null,"Binet formula, sums, combinatorial representations and generating function of the generalized Fibonacci -numbers."),(0,i.kt)("p",null,(0,i.kt)("strong",{parentName:"p"},"Time Complexity:")," O(logn), this is because calculating phi^n takes logn time.",(0,i.kt)("br",{parentName:"p"}),"\n",(0,i.kt)("strong",{parentName:"p"},"Space Complexity:")," O(1)"),(0,i.kt)(v,{mdxType:"CodeBlock"},"\nfunction fib_4(n) {\n let phi = (1 + Math.sqrt(5)) / 2;\n return Math.round(Math.pow(phi, n) / Math.sqrt(5));\n}\n".trim()),(0,i.kt)("h2",null,(0,i.kt)("a",{name:"other-facts"},"Other Facts")),(0,i.kt)("p",null,"Let's look at the other facts where we used in real life."),(0,i.kt)("h3",null,(0,i.kt)("a",{name:"planets-activity"},"Planets Activity")),(0,i.kt)("p",null,"Even our planet activities like Rotations period, Precession Period, Orbital Period are in fibonacci. Refer to Journal of Astronomy on ",(0,i.kt)(F,{url:"http://article.sapub.org/10.5923.j.astronomy.20190801.02.html",mdxType:"ExternalLink"},"Modeling Celestial Mechanics Using the Fibonacci Numbers")),(0,i.kt)("h3",null,(0,i.kt)("a",{name:"golden-ratio"},"Golden Ratio (Phi)")),(0,i.kt)("p",null,"In mathematics, two quantities are in the golden ratio if their ratio is the same as the ratio of their sum to the larger of the two quantities where F",(0,i.kt)("sub",null,"(n+1)")," / F",(0,i.kt)("sub",null,"n")," is most of the time is 1.618"),(0,i.kt)("p",null,"Golden ratio everywhere like example below."),(0,i.kt)("ol",null,(0,i.kt)("li",{parentName:"ol"},"Flower petals"),(0,i.kt)("li",{parentName:"ol"},"Spiral of Pine Cone, Pineapple"),(0,i.kt)("li",{parentName:"ol"},"Storms spin in golden sequence"),(0,i.kt)("li",{parentName:"ol"},"Wave can be measured in this ratio."),(0,i.kt)("li",{parentName:"ol"},"Planet alignment and spirals of our Milky way galaxy"),(0,i.kt)("li",{parentName:"ol"},"Shoulder to elbow and elbow to fingertips will be 1:1.6"),(0,i.kt)("li",{parentName:"ol"},"Finger tips to wrist and wrist to elbow"),(0,i.kt)("li",{parentName:"ol"},"bottom of fingertips to wrist"),(0,i.kt)("li",{parentName:"ol"},"Even your ears, brains, lungs system even helix of our DNA that forms rhythm of our hearbeat."),(0,i.kt)("li",{parentName:"ol"},"Musical scales like piano.")))}Z.isMDXComponent=!0}}]); \ No newline at end of file diff --git a/docs/_next/static/chunks/framework-2191d16384373197bc0a.js b/docs/_next/static/chunks/framework-2191d16384373197bc0a.js new file mode 100644 index 0000000..c4f1aa3 --- /dev/null +++ b/docs/_next/static/chunks/framework-2191d16384373197bc0a.js @@ -0,0 +1 @@ +(self.webpackChunk_N_E=self.webpackChunk_N_E||[]).push([[774],{2703:function(e,t,n){"use strict";var r=n(414);function l(){}function a(){}a.resetWarningCache=l,e.exports=function(){function e(e,t,n,l,a,o){if(o!==r){var u=new Error("Calling PropTypes validators directly is not supported by the `prop-types` package. Use PropTypes.checkPropTypes() to call them. Read more at http://fb.me/use-check-prop-types");throw u.name="Invariant Violation",u}}function t(){return e}e.isRequired=e;var n={array:e,bool:e,func:e,number:e,object:e,string:e,symbol:e,any:e,arrayOf:t,element:e,elementType:e,instanceOf:t,node:e,objectOf:t,oneOf:t,oneOfType:t,shape:t,exact:t,checkPropTypes:a,resetWarningCache:l};return n.PropTypes=n,n}},5697:function(e,t,n){e.exports=n(2703)()},414:function(e){"use strict";e.exports="SECRET_DO_NOT_PASS_THIS_OR_YOU_WILL_BE_FIRED"},4448:function(e,t,n){"use strict";var r=n(7294),l=n(6086),a=n(3840);function o(e){for(var t="https://reactjs.org/docs/error-decoder.html?invariant="+e,n=1;n