MPGH Logistic Programming Challenge

Posts 115 of 33 · Page 1 of 3
MPGH Logistic Programming Challenge
Me, Void, and User1 have been racing to the finish on programs that involve high amounts of preparation and logical thinking to program. Seemingly simple projects may prove to be more difficult than you think.

The main focus of these projects is to use the basic C++ compiler options and make programs that fit the requirements of the challenge. Use this opportunity to think outside the box. Both beginning and advanced programmers can participate.

So here is the first challenge:
Fibonacci Sequence

If you don't know what the Fibonacci Sequence is, refer to this Wikipedia link: Fibonacci number - Wikipedia, the free encyclopedia
Basically, you can find a number in a sequence by adding the two numbers before it together.
Your job is to make a program that is able find the nth term of the Fibonacci Sequence.

Paste your code into a reply when you are done.
More challenges will come as we come up with more ideas through Skype.
something like this??

Code:
int number( int nth )
{
      if( nth<=1 )
      return nth;
      else
            return  number( nth - 1 ) + number( nth - 2 );
}
ofc to lazy to enter the user input but is that needed?
Quote Originally Posted by faceofdevil View Post
something like this??

Code:
int number( int nth )
{
      if( nth<=1 )
      return nth;
      else
            return  number( nth - 1 ) + number( nth - 2 );
}
ofc to lazy to enter the user input but is that needed?
makes it easier on us. lol
Did we tell you we finished Pascal's triangle... ofc i ended up getting it first... he finally got the algorithm after I enhanced my function and allowed user to specify how many levels to calculate... the numbers were HUGE after going to 90 levels.... Lucky I'm on a x64... usigned longs :P

Oh and I have bragging rights now. LOL
Code:
#include <iostream>

using namespace std;

int main()
{
    int nth=0;
    long long unsigned int first = 0, second =1, total = 0;
    cout<<"nth?"<<endl;
    cin>>nth;
    
    for(int i=1; i<nth; i++)
    {
           total=first + second;
           first=second;
           second = total;
    }
    
    cout<<total;
    system("pause");
    return 0;
}
Quote Originally Posted by Toxic Waltz View Post
Code:
#include <iostream>

using namespace std;

int main()
{
    int nth=0;
    long long unsigned int first = 0, second =1, total = 0;
    cout<<"nth?"<<endl;
    cin>>nth;
    
    for(int i=1; i<nth; i++)
    {
           total=first + second;
           first=second;
           second = total;
    }
    
    cout<<total;
    system("pause");
    return 0;
}
good job. exactly how i did it. level one passed
Those are the kind of exercises i had on my exams... ._. such as prime numbers too(ex). On my C exams
Quote Originally Posted by 'Bruno View Post
Those are the kind of exercises i had on my exams... ._. such as prime numbers too(ex). On my C exams
wow ur good. prime numbers was one of the projects me void and user1 were working on yesterday afternoon
Quote Originally Posted by scimmyboy View Post
wow ur good. prime numbers was one of the projects me void and user1 were working on yesterday afternoon
isn;t that difficult....
Quote Originally Posted by scimmyboy View Post
wow ur good. prime numbers was one of the projects me void and user1 were working on yesterday afternoon
i'm not that good... but i must say i hate those exercises.. ;s maybe because of exams /
Code:
#include <windows.h>
#include <iostream>
using namespace std;

int WhatTheFuck(int lolwat);

int main()
{
    while(1)
    {
        int gtfo;
        cout<<"Input: ";
        cin>>gtfo;
        cout<<"Output: "<<WhatTheFuck(gtfo)<<endl;
    }
    return 1;
}

int WhatTheFuck(int lolwat)
{
    if(lolwat<2) return 0;
    else return ((lolwat-1)+(lolwat-2));
}
can't be arsed to test

edit - alternitive:
Code:
#include <windows.h>
#include <iostream>
using namespace std;

int WhatTheFuck(int lolwat);

int main()
{
    cout<<"That guys sequence goes: ";
    for(int i=0;i<100;i++)
    {
        cout<<WhatTheFuck(i);
        if((i%10)==9) cout<<endl;
        else cout<<", ";
    }
    return 1;
}

int WhatTheFuck(int lolwat)
{
    if(lolwat<2) return 0;
    else return ((lolwat-1)+(lolwat-2));
}
Can't believe you're going through with this Justin. |:

By the way, me and User1 have bragging rights over you until you finish the triangle.
Quote Originally Posted by Toxic Waltz View Post
lol HD's code fails
The only thing I have read from this is:
Quote Originally Posted by scimmy
Basically, you can find a number in a sequence by adding the two numbers before it together.
and



so /care if it fails
Quote Originally Posted by Void View Post
Can't believe you're going through with this Justin. |:

By the way, me and User1 have bragging rights over you until you finish the triangle.
./\
/__\



/
Posts 115 of 33 · Page 1 of 3

Post a Reply

Similar Threads

Tags for this Thread

None

Need help?