hacker.org Forum Index
RegisterSearchFAQMemberlistUsergroupsLog in
Big Fib
Goto page Previous  1, 2, 3
 
Reply to topic    hacker.org Forum Index » Challenges View previous topic
View next topic
Big Fib
Author Message
Grevas



Joined: 16 Oct 2010
Posts: 8

Post Reply with quote
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 (~5min sounds about right, running it on one core only)
Tue Nov 01, 2011 8:38 pm View user's profile Send private message
speedfire



Joined: 29 Jul 2012
Posts: 11

Post Reply with quote
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.
Sun Aug 12, 2012 2:03 pm View user's profile Send private message
contagious



Joined: 12 May 2009
Posts: 35
Location: Greece

Post Reply with quote
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"? Twisted Evil

Anyway you are on "hacker.org", this means you are supposed to tackle problems in a smart way.

Good luck!
Sun Aug 12, 2012 2:12 pm View user's profile Send private message
gowron



Joined: 20 Sep 2010
Posts: 9

Post Why not use some tools? Reply with quote
Is using math software considered cheating? I was amazed how quickly maple calculated the fib number (using the closed-form solution, I guess).
Sat Aug 18, 2012 12:25 am View user's profile Send private message
AMindForeverVoyaging
Forum Admin


Joined: 28 May 2011
Posts: 482
Location: Germany

Post Re: Why not use some tools? Reply with quote
gowron wrote:
Is using math software considered cheating?


Of course not.
Sat Aug 18, 2012 12:31 pm View user's profile Send private message
contagious



Joined: 12 May 2009
Posts: 35
Location: Greece

Post Re: Why not use some tools? Reply with quote
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!
Sat Aug 18, 2012 1:02 pm View user's profile Send private message
DEADD00D



Joined: 14 Jul 2014
Posts: 1

Post Reply with quote
// 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));
}
}

_________________
/* Life runs on code */
Sat Sep 20, 2014 4:12 pm View user's profile Send private message
Display posts from previous:    
Reply to topic    hacker.org Forum Index » Challenges All times are GMT
Goto page Previous  1, 2, 3
Page 3 of 3

 
Jump to: 
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum


Powered by phpBB © 2001, 2005 phpBB Group
Design by Freestyle XL / Flowers Online.