Find prime numbers in to 10 fibonacci series

  c++, fibonacci, math

Hey bro I need help to find prime numbers in to 10 Fibonacci numbers I mean between (0-1-1-2-3-5-8-13-21 -34). I think I should make two functions first for 10 Fibonacci numbers and second for how to find prime numbers and actually I know how to write them but how can I combine them??? (I need the program to be very simple)

Here is the code which I wrote:

#include <iostream>
using namespace std;
bool isPrime () {
    int counter;
    for (int a = 1; a <= sum; a++) {
        if (sum % a == 0) {
            counter++;
        }
        if (counter == 2) {
            return true;
        } else {
            return false;
        }
    }
}

void fibonacci () {
    int first = 0, second = 1, sum = 0;
    for (int i = 0; i < 10; i++) {
        if (i <= 1) {
            sum = i;
        } else {
            sum = first + second;
            first = second;
            second = sum;
        }
        cout << sum << " ";
        isPrime();
    }
}

int main() {
    fibonacci();
}

Source: Windows Questions C++

LEAVE A COMMENT