Assignment 6
Assignment 6
2024)
Design a class FiboPrime which will display all the Fibonacci no.s upto nth
term which have atleast one prime digit in the no.
For ex: 2,3,5,13,21 are the examples of Fibonacci no. having atleast one
prime digit in it.
Class Name: FiboPrime
Data Members: int n (No. of terms)
Member Functions:
FiboPrime(int): Parameterized constructor method
int fibo (int n): Returns the nth fibonacci no. using recursive technique
void display (FiboPrime): Display all the fibonacci no.s upto n terms which
have atleast one digit as prime
boolean isprime (int p, int i): Return true or false if p is either prime no. or
not using recursive technique
Algorithm:
1. Class Definition and Setup
Define a class named FiboPrime with:
o Data Member:
Steps:
small.
Exit the program.
3. Method display()
Purpose: Display Fibonacci numbers that contain at least one prime
the result in s.
While s is greater than 0:
it in p.
Call isprime(p, 2) to check if p is a prime number.
number.
Break out of the loop as a prime digit has been
Steps:
Steps:
Class Description
FiboPrime Contains methods to find Fibonacci prime numbers up to
nth term
OUTPUT: