README.md (5164B)
1 <!-- 2 3 @license Apache-2.0 4 5 Copyright (c) 2019 The Stdlib Authors. 6 7 Licensed under the Apache License, Version 2.0 (the "License"); 8 you may not use this file except in compliance with the License. 9 You may obtain a copy of the License at 10 11 http://www.apache.org/licenses/LICENSE-2.0 12 13 Unless required by applicable law or agreed to in writing, software 14 distributed under the License is distributed on an "AS IS" BASIS, 15 WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 16 See the License for the specific language governing permissions and 17 limitations under the License. 18 19 --> 20 21 # iterNonFibonacciSeq 22 23 > Create an iterator which generates a [non-Fibonacci integer sequence][fibonacci-number]. 24 25 <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. --> 26 27 <section class="intro"> 28 29 The nth [non-Fibonacci number][fibonacci-number] is given by 30 31 <!-- <equation class="equation" label="eq:nonfibonacci_number" align="center" raw="f(n) = \left \lfloor{ n + 1 + \log_\varphi \biggl( \sqrt{5}( n + 1 + \log_\varphi(\sqrt{5}(n+1))) - 5 + \tfrac{3}{n+1} \biggr) - 2 } \right \rfloor" alt="Formula to compute the nth non-Fibonacci number."> --> 32 33 <div class="equation" align="center" data-raw-text="f(n) = \left \lfloor{ n + 1 + \log_\varphi \biggl( \sqrt{5}( n + 1 + \log_\varphi(\sqrt{5}(n+1))) - 5 + \tfrac{3}{n+1} \biggr) - 2 } \right \rfloor" data-equation="eq:nonfibonacci_number"> 34 <img src="https://cdn.jsdelivr.net/gh/stdlib-js/stdlib@aa77a2f6e76d2e9da5b49bffa45ee5167d6c16e1/lib/node_modules/@stdlib/math/iter/sequences/nonfibonacci/docs/img/equation_nonfibonacci_number.svg" alt="Formula to compute the nth non-Fibonacci number."> 35 <br> 36 </div> 37 38 <!-- </equation> --> 39 40 where `φ` is the [golden ratio][golden-ratio]. 41 42 </section> 43 44 <!-- /.intro --> 45 46 <!-- Package usage documentation. --> 47 48 <section class="usage"> 49 50 ## Usage 51 52 ```javascript 53 var iterNonFibonacciSeq = require( '@stdlib/math/iter/sequences/nonfibonacci' ); 54 ``` 55 56 #### iterNonFibonacciSeq( \[options] ) 57 58 Returns an iterator which generates a [non-Fibonacci integer sequence][fibonacci-number]. 59 60 ```javascript 61 var it = iterNonFibonacciSeq(); 62 // returns <Object> 63 64 var v = it.next().value; 65 // returns 4 66 67 v = it.next().value; 68 // returns 6 69 70 v = it.next().value; 71 // returns 7 72 73 // ... 74 ``` 75 76 The returned iterator protocol-compliant object has the following properties: 77 78 - **next**: function which returns an iterator protocol-compliant object containing the next iterated value (if one exists) assigned to a `value` property and a `done` property having a `boolean` value indicating whether the iterator is finished. 79 - **return**: function which closes an iterator and returns a single (optional) argument in an iterator protocol-compliant object. 80 81 The function supports the following `options`: 82 83 - **iter**: number of iterations. Default: `1e308`. 84 85 By default, the function returns an infinite iterator (i.e., an iterator which never ends). To limit the number of iterations, set the `iter` option. 86 87 ```javascript 88 var opts = { 89 'iter': 2 90 }; 91 var it = iterNonFibonacciSeq( opts ); 92 // returns <Object> 93 94 var v = it.next().value; 95 // returns 4 96 97 v = it.next().value; 98 // returns 6 99 100 var bool = it.next().done; 101 // returns true 102 ``` 103 104 </section> 105 106 <!-- /.usage --> 107 108 <!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 109 110 <section class="notes"> 111 112 ## Notes 113 114 - If an environment supports `Symbol.iterator`, the returned iterator is iterable. 115 116 </section> 117 118 <!-- /.notes --> 119 120 <!-- Package usage examples. --> 121 122 <section class="examples"> 123 124 ## Examples 125 126 <!-- eslint no-undef: "error" --> 127 128 ```javascript 129 var iterNonFibonacciSeq = require( '@stdlib/math/iter/sequences/nonfibonacci' ); 130 131 // Create an iterator: 132 var opts = { 133 'iter': 100 134 }; 135 var it = iterNonFibonacciSeq( opts ); 136 137 // Perform manual iteration... 138 var v; 139 while ( true ) { 140 v = it.next(); 141 if ( v.done ) { 142 break; 143 } 144 console.log( v.value ); 145 } 146 ``` 147 148 </section> 149 150 <!-- /.examples --> 151 152 <!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 153 154 * * * 155 156 <section class="references"> 157 158 ## References 159 160 - Gould, H.W. 1965. "Non-Fibonacci Numbers." _Fibonacci Quarterly_, no. 3: 177–83. [<http://www.fq.math.ca/Scanned/3-3/gould.pdf>][@gould:1965a]. 161 - Farhi, Bakir. 2011. "An explicit formula generating the non-Fibonacci numbers." _arXiv_ abs/1105.1127 \[Math.NT] (May): 1–5. [<https://arxiv.org/abs/1105.1127>][@farhi:2011a]. 162 163 </section> 164 165 <!-- /.references --> 166 167 <!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. --> 168 169 <section class="links"> 170 171 [fibonacci-number]: https://en.wikipedia.org/wiki/Fibonacci_number 172 173 [golden-ratio]: https://en.wikipedia.org/wiki/Golden_ratio 174 175 [@gould:1965a]: http://www.fq.math.ca/Scanned/3-3/gould.pdf 176 177 [@farhi:2011a]: https://arxiv.org/abs/1105.1127 178 179 </section> 180 181 <!-- /.links -->