---
title: "samuel (@abiodunjames) | Hashnode"
description: "I code and I speak. Read the latest articles by samuel on Hashnode."
url: "https://hashnode.com/@abiodunjames"
---

@abiodunjames

# samuel

@abiodunjames · Joined December 2019

I code and I speak

[Website](https://hubofco.de/)

## Comments

[To solve this problem, we'll use generator in Javascript. A generator is a function that returns (yield) sequence of results instead of a single result. We define a generator function in JS as: function\* fibonacci(){ // to be implemented } We implement the function above as: function\* fibonacci() { let a = 0, b = 1; while (true) { yield a a = b, b =a +b; } } You can test it like this: const result = fibonacci() console.log(result.next().value); //0 console.log(result.next().value); // 1 console.log(result.next().value); // 2 console.log(result.next().value); // 4 console.log(result.next().value); // 8 console.log(result.next().value); //16 Each time you call result.next().value, a new fibonacci number will be returned](https://hashnode.com/forums/thread/can-you-write-a-generator-function-which-will-return-unlimited-fibonacci-numbers/comment/5e21518132d5fad159b6f6cf)

Comment · Thread · Jan 17, 2020 · [Can you write a generator function which will return unlimited Fibonacci numbers?](https://hashnode.com/forums/thread/can-you-write-a-generator-function-which-will-return-unlimited-fibonacci-numbers)
