pistone's blog

By pistone, 13 years ago, In English

for me it wa quite a problem , since i strictly used C++ to solve it.

  • Vote: I like it
  • 0
  • Vote: I do not like it

| Write comment?
13 years ago, # |
  Vote: I like it 0 Vote: I do not like it

my fault , sorry 

actually the problem is :  finding the minimum c++ variable type(byte,short,int,long etc)  in which nth fibonacci number can be accomodated .
 
if it cant be accomodated in c++ standard var types then print  "BigInteger" .

  • 13 years ago, # ^ |
    Rev. 2   Vote: I like it 0 Vote: I do not like it

    It is all the same, just use log2 instead of log10.

    However, since Fibonacci sequence grows fast, you can write program for direct computation.

    UPD: Or you mean "help me to write the program for Fibonacci sequence computation?"
13 years ago, # |
Rev. 2   Vote: I like it 0 Vote: I do not like it

You can just generate locally all those Fib numbers and remember n values: ai is such that Fai is a max number that fits in ith type.
After that just some if's.