For rabbits, answer is 256. On Sat, Jul 30, 2011 at 8:33 PM, Tushar Bindal <[email protected]>wrote:
> for rabbits answer would be different from cows as they give birth to a > pair at a time, so at any time odd number of rabbits won't be there > > > On Sat, Jul 30, 2011 at 9:13 AM, Reynald Suz <[email protected]>wrote: > >> Thank ya shiv, agarwal and Anders. >> >> >> On Sat, Jul 30, 2011 at 8:10 AM, Anders Ma <[email protected]> wrote: >> >>> anders@anders-Satellite-U400:~/puzzle$ cat novel_she_calf.c >>> #include <stdio.h> >>> >>> /* >>> iIf a cow produces its first she-calf at age two years and after that >>> produces another single she-calf every year, how many she-calves are >>> there after 12 years? assuming none die. >>> */ >>> >>> unsigned int she_calves(unsigned int year) >>> { >>> unsigned int one_year = 0; >>> unsigned int two_year = 1; >>> unsigned int tmp; >>> >>> while (year--) { >>> tmp = one_year; >>> one_year += two_year; >>> two_year = tmp; >>> } >>> return one_year + two_year - 1; >>> } >>> >>> int main (int argc, char** argv) >>> { >>> unsigned int number; >>> >>> if (argc != 2) { >>> printf("[usage]: she_calves [year]\n"); >>> return 0; >>> } >>> number = she_calves(atoi(argv[1])); >>> printf("After %d years, she-calves number is %d\n", atoi(argv[1]), >>> number); >>> } >>> anders@anders-Satellite-U400:~/puzzle$ gcc novel_she_calf.c -o >>> she_calves >>> anders@anders-Satellite-U400:~/puzzle$ ./she_calves 12 >>> After 12 years, she-calves number is 232 >>> anders@anders-Satellite-U400:~/puzzle$ >>> >>> >>> >>> -- >>> Regards >>> Anders >>> >>> -- >>> You received this message because you are subscribed to the Google Groups >>> "Algorithm Geeks" group. >>> To post to this group, send email to [email protected]. >>> To unsubscribe from this group, send email to >>> [email protected]. >>> For more options, visit this group at >>> http://groups.google.com/group/algogeeks?hl=en. >>> >>> >> >> >> -- >> Regards >> Reynald Reni >> Masters in Software Engineering >> CIT - India >> >> -- >> You received this message because you are subscribed to the Google Groups >> "Algorithm Geeks" group. >> To post to this group, send email to [email protected]. >> To unsubscribe from this group, send email to >> [email protected]. >> For more options, visit this group at >> http://groups.google.com/group/algogeeks?hl=en. >> > > > > -- > Tushar Bindal > Computer Engineering > Delhi College of Engineering > Mob: +919818442705 > E-Mail : [email protected] > Website: www.jugadengg.com > > -- > You received this message because you are subscribed to the Google Groups > "Algorithm Geeks" group. > To post to this group, send email to [email protected]. > To unsubscribe from this group, send email to > [email protected]. > For more options, visit this group at > http://groups.google.com/group/algogeeks?hl=en. > -- Nikhil Gupta Senior Co-ordinator, Publicity CSI, NSIT Students' Branch NSIT, New Delhi, India -- You received this message because you are subscribed to the Google Groups "Algorithm Geeks" group. To post to this group, send email to [email protected]. To unsubscribe from this group, send email to [email protected]. For more options, visit this group at http://groups.google.com/group/algogeeks?hl=en.
