something like this??
ofc to lazy to enter the user input but is that needed?Code:int number( int nth ) { if( nth<=1 ) return nth; else return number( nth - 1 ) + number( nth - 2 ); }
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??
ofc to lazy to enter the user input but is that needed?Code:int number( int nth ) { if( nth<=1 ) return nth; else return number( nth - 1 ) + number( nth - 2 ); }
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
Any donations would help
Originally Posted by Bombsaway707Originally Posted by BloodOriginally Posted by Alby-kunOriginally Posted by AliOriginally Posted by CodeDemon[21:13] CoderNever: HOLY SHIT ITS USER1!Yes it is me... Yup Yup
[IMG]https://i111.photobucke*****m/albums/n121/golmor/learntoprogram-1.png[/IMG]
Those are the kind of exercises i had on my exams... ._. such as prime numbers too(ex). On my C exams
Last edited by 'Bruno; 08-11-2010 at 07:25 PM.
Light travels faster than sound. That's why most people seem bright until you hear them speak.
can't be arsed to testCode:#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)); }
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)); }
Last edited by Hell_Demon; 08-11-2010 at 09:52 PM.
Ah we-a blaze the fyah, make it bun dem!
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.