Problem 104

A place to air possible concerns or difficulties in understanding ProjectEuler problems. This forum is not meant to publish solutions. This forum is NOT meant to discuss solution methods or giving hints how a problem can be solved.
Forum rules
As your posts will be visible to the general public you are requested to be thoughtful in not posting anything that might explicitly give away how to solve a particular problem.

This forum is NOT meant to discuss solution methods for a problem.

In particular don't post any code fragments or results.

Don't start begging others to give partial answers to problems

Don't ask for hints how to solve a problem

Don't start a new topic for a problem if there already exists one


See also the topics:
Don't post any spoilers
Comments, questions and clarifications about PE problems.
Post Reply
MaJJ
Posts: 49
Joined: Tue Oct 14, 2008 12:14 am

Problem 104

Post by MaJJ »

Given that Fk is the first Fibonacci number for which the first nine digits AND the last nine digits are 1-9 pandigital, find k.
How to interpret it? I can think of at least three ways:

1. Find k for which (isPandigital(First9Digits(Fib(k))) && isPandigital(Last9Digits(Fib(k)))) == true.
That's how I understood the problem at first. I'm unable to do it by bruteforce, it's probably HUGE number and has to be determined by some math tricks.

2. Find k for which isPandigital(First9Digits(Fib(k)) * 109 + Last9Digits(Fib(k))) == true.
This procedure would turn number of any length to number that had only first 9 and last 9 digits of the former. k is then 175 (and Fib(k) = 167244575 9041379840132227567 949787325). The answer form says this is wrong.

3. Find k for which isPandigital(First9Digits(Fib(k)) & Last9Digits(Fib(k))) == true.
This interprets the AND in the problem statement as bitwise AND. k is then 4633, Fib(k) is 776698159...(950 more digits)...138529553, and 776698159 & 138529553 = 138496257, which is pandigital. The answer form says this is also wrong.

Sooo ... how should I understand the question?
Image
Image
TripleM
Posts: 384
Joined: Fri Sep 12, 2008 3:31 am

Re: Problem 104

Post by TripleM »

Your first interpretation is correct.
MaJJ
Posts: 49
Joined: Tue Oct 14, 2008 12:14 am

Re: Problem 104

Post by MaJJ »

Damn, I hoped not to hear that :D Well, let's study Fibonacci numbers... :?
Image
Image
denshade
Posts: 2
Joined: Wed Mar 16, 2011 9:00 pm

Re: Problem 104

Post by denshade »

What order of magnitude is this number k?
I just would like to know if it is worth waiting for my algorithm or not...
User avatar
jaap
Posts: 588
Joined: Tue Mar 25, 2008 3:57 pm
Contact:

Re: Problem 104

Post by jaap »

It has 6 digits.
User avatar
SoboLAN
Posts: 39
Joined: Sat Aug 18, 2012 3:21 pm

Re: Problem 104

Post by SoboLAN »

I used your first interpretation too. I started the program and, after about 30 minutes it reached k = 100 thousand. The result was still not found.

I just have no idea how to solve this in another way. Maybe I should just let it run for 2 hours or so and get the result.

EDIT: I did it in 115 seconds. However, I don't understand the (fast and genious) solutions posted on the problem's thread. Those people just explain what solution they used, not WHY that solution WORKS. Don't just assume everyone understands those things...
Image
whakamaru
Posts: 47
Joined: Thu May 06, 2010 11:08 pm

Re: Problem 104

Post by whakamaru »

I wonder why PE didn't set the question to find all ten digits? That is what I was looking for, until... I read the question again! I think the first f(n) with the last TEN digits pan, is around the 11,000 mark.
pimspelier
Posts: 41
Joined: Tue Jan 21, 2014 2:06 pm
Location: The Netherlands

Re: Problem 104

Post by pimspelier »

Could someone confirm these values:
for the last 9 digits, these are pandigital:
F_996271,F_997031,F_998987

for the first 9 digits:
F_992229,F_994961,F_997942

As first values I do get 541 and 2749, but I'm worried it's not exact enough... Also, is it true that
It has six digits
, because my first value is around 4.5 million
Image
User avatar
dawghaus4
Posts: 56
Joined: Fri Nov 29, 2013 2:22 am

Re: Problem 104

Post by dawghaus4 »

It is true that the answer is 6 digits long.

If I understand you correctly, only one of your "last" values is correct. The last 9 digits of F996271 are 1-9 pandigital. All of your ""first values are correct.

There are two Fibonacci numbers with 7-digit indices that have the desired properties, but both indices are greater than 6,000,000. The fourth such number has an index of almost 17,000,000.

On edit: Corrected serious misstatement in second paragraph. See two posts down.
Last edited by dawghaus4 on Mon Jun 02, 2014 8:52 pm, edited 1 time in total.
pimspelier
Posts: 41
Joined: Tue Jan 21, 2014 2:06 pm
Location: The Netherlands

Re: Problem 104

Post by pimspelier »

Thanks!
EDIT: I've checked again, and are the rest of the values (for first and last digits) off by one?
EDIT: The values of k when the last 9 digits are pandigital, were off by one when k was even... stupid mistake, one i++ was where it shouldn't be.
Image
User avatar
dawghaus4
Posts: 56
Joined: Fri Nov 29, 2013 2:22 am

Re: Problem 104

Post by dawghaus4 »

I agree that the last digits of F997032 and F998988 are 1-9 pandigital.

I must also confess a stupid error that resulted from my asking my program to do something it wasn't designed to do.

Your three Fibonacci number candidates that for the first 9 digits to be 1-9 pandigital are in fact just that. I hope that I haven't caused you much delay or undue work. I'm surprised no one jumped in to correct my mistake. Perhaps, like my program, their programs are designed to do that.

(My error, the program didn't correctly calculate the first 9 digits until the last 9 digits were pandigital. I just went back and isolated that part of the code to confirm your original claim.)

I reverified my statements about the first 4 numbers that are 1-9 pandigital at the beginning and end. The program is design to do that.

Again, my apologies.
User avatar
RishadanPort
Posts: 79
Joined: Mon Jun 10, 2013 7:31 am

Re: Problem 104

Post by RishadanPort »

How long is this solution suppose to take to solve?

I have the correct solution, and I am using correct operations on C# BigIntegers -- but takes looooooong time.
Image

Rishada is the gateway to free trade—but the key will cost you.
User avatar
RishadanPort
Posts: 79
Joined: Mon Jun 10, 2013 7:31 am

Re: Problem 104

Post by RishadanPort »

hm oh well I solved it in 233 seconds
Image

Rishada is the gateway to free trade—but the key will cost you.
User avatar
dawghaus4
Posts: 56
Joined: Fri Nov 29, 2013 2:22 am

Re: Problem 104

Post by dawghaus4 »

My program solves the problem in 0.048722 seconds (2.6 GHz Intel core I7). It doesn't use big integers.
Post Reply