# Fibonacci challenge

• (3 Pages)
• 1
• 2
• 3

## 38 Replies - 32498 Views - Last Post: 21 February 2015 - 06:49 AM

### #31 p.mo

Reputation: 1
• Posts: 1
• Joined: 02-October 12

## Re: Fibonacci challenge

Posted 02 October 2012 - 07:58 PM

This is my first post and challenge. While its not very compact should be functional functional.

Spoiler

### #32 HB-aka

Reputation: 0
• Posts: 62
• Joined: 03-June 14

## Re: Fibonacci challenge

Posted 09 June 2014 - 03:02 AM

this function will get Fibonacci numbers.
i used "long integers" because the number can get to big.
so...this is the code i'v made.
Spoiler

This post has been edited by Skydiver: 09 June 2014 - 08:22 PM
Reason for edit:: Put code in spoiler tags to keep challenge fresh for late comers.

### #33 tifuy95

Reputation: 0
• Posts: 1
• Joined: 26-September 14

## Re: Fibonacci challenge

Posted 26 September 2014 - 11:20 AM

I am a new programer can someone give me feedback on my code??
```// Made by Max Bentata

//09/21/2014

#include <iostream>
using namespace std;

int main()
{
int x = 0;
int fib = 0;
int sum = 1;
int marker = 0;

cout << x << endl;
x = fib + sum;
cout << x << endl;
fib = x + sum;
cout << fib << endl;

x = fib + sum;
cout << x << endl;

while (mkr < 15){
sum = x + fib;
cout << sum << endl;
fib = sum + x;
cout << fib << endl;
x = fib + sum;
cout << x << endl;
marker++;
}

return 0;
}

```

### #34 compscistud

Reputation: 0
• Posts: 17
• Joined: 21-October 14

## Re: Fibonacci challenge

Posted 18 November 2014 - 01:20 AM

this was my assignment last week lol

### #35 vividexstance

• D.I.C Lover

Reputation: 719
• Posts: 2,483
• Joined: 31-December 10

## Re: Fibonacci challenge

Posted 18 November 2014 - 12:04 PM

tifuy95, on 26 September 2014 - 01:20 PM, said:

I am a new programer can someone give me feedback on my code??
```// Made by Max Bentata

//09/21/2014

#include <iostream>
using namespace std;

int main()
{
int x = 0;
int fib = 0;
int sum = 1;
int marker = 0;

cout << x << endl;
x = fib + sum;
cout << x << endl;
fib = x + sum;
cout << fib << endl;

x = fib + sum;
cout << x << endl;

while (mkr < 15){
sum = x + fib;
cout << sum << endl;
fib = sum + x;
cout << fib << endl;
x = fib + sum;
cout << x << endl;
marker++;
}

return 0;
}

```

One thing that stood out for me is that you use what are called "Magic Numbers", specifically, the while(marker < 15). What is that 15 supposed to represent? Would it be used more than once if this were a larger program? If so, what happens when you want to change the 15 to something else? You would have to go through the code and replace the number and hope that you don't miss any, or if you do, that it will be noticed and easily found.

The tip, would be to use a variable, specifically, a const variable that doesn't change throughout the program. This way, you can give the number a descriptive name which helps people reading the code to understand it a little easier. Also, it makes changing/maintaining the code easier because you only have to make the change in one place instead of many.

### #36 9644026902

Reputation: 0
• Posts: 1
• Joined: 27-November 14

## Re: Fibonacci challenge

Posted 27 November 2014 - 08:03 AM

Spoiler

This post has been edited by Skydiver: 22 January 2015 - 10:48 PM
Reason for edit:: Put code in spoiler tags.

### #37 fj_j_greenhalgh

Reputation: 0
• Posts: 1
• Joined: 05-December 14

## Re: Fibonacci challenge

Posted 05 December 2014 - 06:04 PM

Template Metaprogramming C++11

Spoiler

This post has been edited by Skydiver: 22 January 2015 - 10:47 PM
Reason for edit:: Put code in spoiler tags.

### #38 Skydiver

• Code herder

Reputation: 3868
• Posts: 12,228
• Joined: 05-May 12

## Re: Fibonacci challenge

Posted 22 January 2015 - 10:47 PM

fj_j_greenhalgh: See post #27.

### #39 its_MCD

Reputation: 0
• Posts: 1
• Joined: 21-February 15

## Re: Fibonacci challenge

Posted 21 February 2015 - 06:49 AM

I found a way to make a function for fibonacci's formula by using ading ect.
```int fibonacci(){
unsigned long long int nom1 = 0;
unsigned long long int nom2 = 1;

while(nom2 < 999999999){
printf("%d \n",nom1 + nom2);
int nom3 = nom1 + nom2;
printf("%d \n",nom2 + nom3);
nom1 = nom2 + nom3;
printf("%d \n",nom3 + nom1);
nom2 = nom3 + nom1;

}

return 0;}
```

its_MCD, on 21 February 2015 - 06:48 AM, said:

I found a way to make a function for fibonacci's formula by using ading ect.
```int fibonacci(){
unsigned long long int nom1 = 0;
unsigned long long int nom2 = 1;

while(nom2 < 999999999){
printf("%d \n",nom1 + nom2);
int nom3 = nom1 + nom2;
printf("%d \n",nom2 + nom3);
nom1 = nom2 + nom3;
printf("%d \n",nom3 + nom1);
nom2 = nom3 + nom1;

}

return 0;}
```
sorry i don't know how the code should come

• (3 Pages)
• 1
• 2
• 3

 .related ul { list-style-type: circle; font-size: 12px; font-weight: bold; } .related li { margin-bottom: 5px; background-position: left 7px !important; margin-left: -35px; } .related h2 { font-size: 18px; font-weight: bold; } .related a { color: blue; }