# Fibonacci numbers with Function array

**URL:** https://discourse.processing.org/t/fibonacci-numbers-with-function-array/4145
**Category:** Coding Questions
**Tags:** homework
**Created:** [October 4, 2018, 8:37pm UTC](https://discourse.processing.org/t/fibonacci-numbers-with-function-array/4145 "2018-10-04T20:37:48Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![gisue](https://avatars.discourse-cdn.com/v4/letter/g/3e96dc/32.png) [@gisue](https://discourse.processing.org/u/gisue)
#### Post date: [October 4, 2018, 8:37pm UTC](https://discourse.processing.org/t/fibonacci-numbers-with-function-array/4145/1 "2018-10-04T20:37:48Z")

</div>

How can we use array function for Fibonacci?  
I want to dynamically increase the Array by adding  
the next Fibonacci numbers. I need to use Processing Array Function  
and rewrite function fibNumber with integer array fibNums.

```auto
int	num	=	1000000;	
void	setup(){	
		noLoop();	
}	
void	draw(){	
		fibNumber(0,	1,	num);	
}	
void	fibNumber(int	x0,	int	x1,	int	num){	
		if(x1	<	num){	
				//println(x0+x1);	
fibNumber(x1,	x0+x1,	num);	
				//println(x0+x1);	
		}	
}

```

---

<div class="post-metadata">

### Author: ![tony](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tony/32/949_2.png) [@tony](https://discourse.processing.org/u/tony)
#### Post date: [October 4, 2018, 8:59pm UTC](https://discourse.processing.org/t/fibonacci-numbers-with-function-array/4145/2 "2018-10-04T20:59:50Z")

</div>

Please clarify your question. I’m mostly confused by this line:

> [@gisue](#):
>
> I need to use Processing Array Function  
> and rewrite function fibNumber with integer array fibNums.

Because you haven’t initialized an array called fibNums yet. Can I ask if this is for a class or something?

---

<div class="post-metadata">

### Author: ![gisue](https://avatars.discourse-cdn.com/v4/letter/g/3e96dc/32.png) [@gisue](https://discourse.processing.org/u/gisue)
#### Post date: [October 4, 2018, 9:05pm UTC](https://discourse.processing.org/t/fibonacci-numbers-with-function-array/4145/3 "2018-10-04T21:05:17Z")

</div>

this is for my assignment for class.

This is my code , please help me to edit it.

```auto

int [] fibNum;

void setup() {  
  size(400, 400);  
  noStroke();  
  smooth();  
  noLoop();  

  background(204); 
  fibNum = new int[width];
}
void draw() {  
  background(204);  
  for (int i = 0; i <fibNum.length-1; i++) {      
    fibNum[i+1] = fibNum[i]+ fibNum[0];
  }

  PrintfibNum[i];

```

---

<div class="post-metadata">

### Author: ![tony](https://yyz2.discourse-cdn.com/flex036/user_avatar/discourse.processing.org/tony/32/949_2.png) [@tony](https://discourse.processing.org/u/tony)
#### Post date: [October 4, 2018, 9:18pm UTC](https://discourse.processing.org/t/fibonacci-numbers-with-function-array/4145/4 "2018-10-04T21:18:13Z")

</div>

Do you understand the differences between the `draw()` and `setup()` functions?
