##### [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

**RANK 3 :** @fuzzyastrocat and @Coder100

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!

### PRIME FIBONACCI!

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.

**SUBMISSION**

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`#WEEKLY`

in their name, even`WEEKLY`

is fine.

And that's it for today, code away and have fun replers!

**UPDATE**

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.

test

@poetaetoes Yeah, I saw that my weekly 19 was scored but he hasn't released the scores either.

Fortran is awesome! I can get the first 12 in like 20 seconds. LOL!

@AmazingMech2418 Using ratfor?

@CodeLongAndPros What? I just used 16-byte integers. Fortran generally produces faster binaries than C/C++ and I think even Rust.

@AmazingMech2418 Ratfor allows if-then and while loops

@CodeLongAndPros I just used Fortran 90...

@AmazingMech2418 OOF why didn't I think of this, lol FORTRAN is like *the* data science programming language

Jeez, is this a google interview?

no constraints?

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.

i just lost hacker plan lolol

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

@SpicedSpices as said above, the actual program needs to be capable of up to 10th term practically. The rest should be possible "theoretically".

@TheDrone7 hmm so "theoretically" means that we don't have to worry about integer limits?

@SpicedSpices well yes. I only need a working algorithm that could calculate them if there were no limits.

@TheDrone7 oh ok thank you for clarifying

My repl from last week didn't seem to get scored.

@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.

So, basically, the challenge is to return n amount of terms of the "prime" fibonacci sequence right? Also, we can use loops and recursions this time right?

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.

@xxpertHacker 1 is neither prime nor composite. So the first term is 2.

@xxpertHacker and as for sample input and outputs, there's 4 of them given in the challenge with explanation on how to achieve them.

@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.

I give up at weekly challenges. :(

pog

50 or infinite or ask

Would it be OK to have a list of prime numbers (calculated on the spot) and checking if a fib number is in it?

@firefish You'll probably get deducted pts for that

@HarperframeInc Thought of another plan then

@TheDrone7 Ok, that'll make it a tad slow, but so be it...

This file cannot be displayed: https://weeklywidget.harperframeinc.repl.co

@TheDrone7 I made a dynamic image displaying the leaderboard ^^^

Btw typo in post

WEEKLY 18 Results

Here are the results for the weekly challenge #17.

Should be weekly challenge #18 xD

@CoolJames1610 ah yes, thanks

Wow 8 points thanks!!!

._.

Ayyy, I got 3rd rank! Yay!

Nice job to everyone else, this was a fun one. Next one looks fun too!

darn it i was about to finish

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 34provenfibonacci primes. Not 50.So are you looking for a working program that theoretically could do it? Or you want an

actualprototype?@HarperframeInc Parallelism, concurrency, efficient algorithms, umm... and some more stuff.

I've got both, an efficient Fibonacci function and an efficient prime finder, let's see how this works.

@HarperframeInc Update: just ran my code, seemed to run pretty fast, but then overflowed the stack after the 11th number. :)

@HarperframeInc have you tried quantum computing? heard those were pretty fast

@HarperframeInc Yeah, I have no idea how this is possible.

@HarperframeInc exactly.

@DynamicSquid Quantum computing is great for only certain types of code, here it would ineffective.

@DynamicSquid lol

@xxpertHacker That's nice, but primes are one of a kind. It's like finding a needle in a hay stack except your 1 needle is in 100K hay stacks

@HarperframeInc Lol, my Haskell program "can" do it but it gets hung up on the 8th number, even with laziness and fairly efficient algorithms... I'm really stumped here

@fuzzyastrocat Same with my program. I haven't gotten any crashed programs so I'm suggesting that it can do it, it's just not as efficent and needs a better processor.

@HarperframeInc Yay now I can get to 11, still gets stuck there tho... I guess I've reached @xxpertHacker's program's performance now

@fuzzyastrocat Ha, I honestly wanna check your Repls to see if we did the same thing.

@xxpertHacker https://repl.it/@fuzzyastrocat/FibPrime

@HarperframeInc You say it as if you need to "find" primes, as if it's just by chance. My program makes it look like light-work: https://repl.it/@xxpertHacker/weekly-19#main.rs

@fuzzyastrocat Ahh, I see. I was thinking about ditching my current setup, then creating 2 arrays of values, then finding their intersections, it would be efficient, but mutative and impure. Watch me ditch my Rust and use a simple JavaScript array lol.

@xxpertHacker Yeah I tried doing lazy intersection with the cartesian product, but it yielded bad performance. I changed it to

`filter isPrime fibs`

and it greatly increased performance, so trying to rework my matrix fib solution to be more efficient rn.@xxpertHacker Fibbonacci Primes are much bigger than that my friend- your program is puny at finding it

@fuzzyastrocat This challenge is kinda funny, the other ones took me a bit of thinking about just how to achieve the result, now I've already got a few ideas, and need to see how to make it happen computationally.

@xxpertHacker Heh yeah, this one's easy in theory but hard in practice

@HarperframeInc Oh yeah, I messed up my algorithm badly. Debugging it rn.

@HarperframeInc Exactly. The largest known prime fibonacci, the 34th has 21925 digits, which has to be stored in a string. And I'm 99.9% sure there's no way of determining whether a number is prime when it is in string form.

@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.

@HarperframeInc @xxpertHacker Wait, I just realized... there are 34 (i think) known prime fibonacci numbers. This challenge only needs up to 20. So... copy-and-paste into an array? :D

@fuzzyastrocat I thought about just that the first day, but Drone will give a low score for that.

@xxpertHacker @fuzzyastrocat low score? I'd give a 0.

@TheDrone7 @xxpertHacker Yeah, I figured a low score would be given (which is why I'm not actually doing that)... though it doesn't say you have to

calculate, justgenerate, but yeah it's a very hacky method of doing it.The real calculating method is more fun anyways :D