0
Finding prime numbers in given fibonacci series
This is a c++ program that I need to find prime numbers of fibonacci series. the question says that after you enter the n ( the number of fibonacci series ) the program has to extract the prime numbers from it, and then, if the sum of those prime numbers is an odd number, it has to show 'A' and if it's even, it should show 'D'. The problem is i know how to find both fibonacci series and prime numbers, but i can't put them together. And i need to keep the code as simple as possible Can someone help me in this?
4 Answers
+ 6
Kimia , before we can help you, you should show us your attempt first. if you have not done a try by yourself upto now, please do so. Put your code in playground and link it here. Thanks!
+ 4
Kimia , what you can do is: (for the moment it's better not to "merge" these two calculations (fibonacci and prime) better try it this way):
âȘïž use one code that contains both calculstions
âȘïž run the code for the fibonacci series first
âȘïž store the resulting numbers in an array or a list
âȘïž after the fibonacci numbers are done, start processing the prime numbers
âȘïž use a loop to iterate through the sequence (array or list) and check each member if it is prime of not
âȘïž print the resulting numbers
that's all! - try to pug it together. if you get stuck, put your code in playground and link it here. thanks!
AND PLEASE: do not use such cryptic variable names. use meaningful identifiers. being lazy here, does not really save time. thanks
+ 1
Lothar thank you so much! I'll try my best
0
Lothar
So this is what i wrote for fibonacci
https://code.sololearn.com/cIMR29J27wT6/?ref=app
And this one is for prime number ( but is shows how many prime numbers are in the given number )
https://code.sololearn.com/cXiww1rV83qD/?ref=app