[UPDATE] Weekly Challenge #19
Hey there replers! 2 weeks ago, we started the 5th batch of repl.it weekly challenges!
So below are the results for the last weekly challenge aka Weekly Challenge #18.
WEEKLY 18 Results
Here are the results for the weekly challenge #18.
RANK 1 : @HarperframeInc
RANK 2 : @Lord_Poseidon
In case you did not make into the top 3, you can check out your score at the weekly results website - https://weekly.thedrone7.repl.co
But before that, here's this week's weekly challenge for you all!
Basically, fibonacci series but instead of using whole numbers, you use prime numbers. The first time will be 2, second term will be 3, and third time will be 2 + 3 = 5. But here comes the tricky part, the term should always be a prime number. So, 5 + 3 = 8 will be invalid, moving forward, 5 + 8 = 13 so 4th term will be 13 (which is prime again). Your program should be able to generate up to 5
20 such terms.
Also, for testing, only the first 10 terms will be checked but it should (at least theoretically) be possible of finding up to 20 terms.
For submitting your repls, post them on the repl talk share board and ensure that they contain
#WEEKLY in their name.
NOTE : You cannot have multiple weekly challenge submissions but if you want to share multiple ways of achieving the goal, you can make regular posts that don't contain
#WEEKLYin their name, even
And that's it for today, code away and have fun replers!
Since calculating up to 50 terms seems to be not possible without the hacker plan (lack of resources). The requirement has been reduced to 20 terms instead.
Wait a minute- How is this possible?
Such a formula would require intense computing power which we don't have- and the last site I've been on was only able to calculate the 21 first primes of Fibonacci. Edit: Wikipedia says there are only has 34 proven fibonacci primes. Not 50.
So are you looking for a working program that theoretically could do it? Or you want an actual prototype?
@HarperframeInc theoretical lol. It's obvious I don't want beginners to do something like that. But aim for the highest number of terms you can calculate. I've decided to reduce the number of required terms since I realised even with most optimisations it would require the hacker plan to actually be able to do it.
Since calculating up to 50 terms seems to be not possible without the hacker plan...
Actually, I have the hacker plan, but I still can't figure out how to get my code to pull it off. It's all about code design.
Ohh, I think I see where I went wrong. I'll probably submit later today.
The 14th Fibonacci prime, 19134702400093278081449423917, is the last one before it overflows past a 128 bit integer. The only way to continue going forth is to add an external library, or to add strings together.
Even the Sieve of Atkin written in Rust, one of the fastest known prime tests, takes almost a minute to tell if 19134702400093278081449423917 is prime. Not even going to think about the other 6.
What's being asking for here is a mathematical miracle, or for us to write code with a runtime of days.
ill keep working on it though, it seems like a fun challenge
@nicholasptheepi practically it should be capable of finding up to the 20th terms although since it can be difficult for people without repl.it hacker plan, testing will only be performed till the 10th term. You can make it capable of finding up to the 50th term theoretically however.
This is impossible. There are only 34 Fibonacci numbers that are proven to be prime. It's not even certain that there ARE 50 primes. Even if there are, the 34th Fibonacci prime has 21925 digits and is the 104911th Fibonacci number. The theoretical 50th Fibonacci prime has 678033 digits and is the 3244369th Fibonacci number. Even if you use strings to store the numbers, you'd need a heck of a lot of either memory or time to compute whether it is prime, depending on the method you use.
If I might ask, could a slightly better description of the expected input and output be given? I think I already see how it's supposed to be, but just for insurance.
Also, isn't "1" a prime number, thus the first term would be "1," not 2?
Update: my logic was implemented incorrectly, 1 isn't prime, I forgot. And I searched it up to get more details already.
@TheDrone7 Yeah, I should've deleted this comment, since I'd already found that there happens to be a whole Wikipedia page on this. Surprisingly, the idea is pretty simple, but the implementation is incredibly difficult. My code is mostly just trying to prevent stack overflows or something of the sort to make this computationally possible.
Would it be OK to have a list of prime numbers (calculated on the spot) and checking if a fib number is in it?