Page 3 of 3
Posted: Tue Nov 01, 2011 8:38 pm
by Grevas
Just in case:
Fib(0) = 0
Fib(1) = 1
Fib(2) = 1
Fib(3) = 2
is currently used in this challenge. Just had a example in my python book about iterations using fibonacci sequence, so i modified it 'slightly'
![Smile :)](./images/smilies/icon_smile.gif)
(~5min sounds about right, running it on one core only)
Posted: Sun Aug 12, 2012 2:03 pm
by speedfire
Oki finally I done it.
I have code a program with a logarithmic algorithme.
But for real... Do you really think everyone are mathematician ?
If you don't know anything about optimisation good luck ! You can wait a long long long time If you don't code proprely.
Posted: Sun Aug 12, 2012 2:12 pm
by contagious
speedfire wrote:Oki finally I done it.
I have code a program with a logarithmic algorithme.
But for real... Do you really think everyone are mathematician ?
If you don't know anything about optimisation good luck ! You can wait a long long long time If you don't code proprely.
If you have struggled with this one, what will you do with "Biggest Fib"?
Anyway you are on "hacker.org", this means you are supposed to tackle problems in a smart way.
Good luck!
Why not use some tools?
Posted: Sat Aug 18, 2012 12:25 am
by gowron
Is using math software considered cheating? I was amazed how quickly maple calculated the fib number (using the closed-form solution, I guess).
Re: Why not use some tools?
Posted: Sat Aug 18, 2012 12:31 pm
by AMindForeverVoyaging
gowron wrote:Is using math software considered cheating?
Of course not.
Re: Why not use some tools?
Posted: Sat Aug 18, 2012 1:02 pm
by contagious
gowron wrote:Is using math software considered cheating? I was amazed how quickly maple calculated the fib number (using the closed-form solution, I guess).
Cheating? haha You are supposed to cheat if u can!
Posted: Sat Sep 20, 2014 4:12 pm
by DEADD00D
// F_1=1, F_2=1, F_n=F_{n-1}+F_{N-2};
// I tend to use Java.math.BigInteger when cope with big numbers, and it's handy.
import java.math.BigInteger;
public class Hacker144
{
private static final int INDEX = 1500000;
private static final int STEP = 20000;
public static void main(String args[])
{
BigInteger f1 = new BigInteger("1");
BigInteger f2 = new BigInteger("1");
for(long i = 1; i < INDEX; ++i)
{
BigInteger tmp = f2;
f2 = f2.add(f1);
f1 = tmp;
}
final String ans = f1.toString();
for(int i = 0; i < ans.length(); i += STEP)
System.out.print(ans.charAt(i));
}
}