Skip to content

Commit 2efd90d

Browse files
committed
up12
1 parent 0bc5970 commit 2efd90d

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

  • JavaPractice/TheFibonacci-primeNumber
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
## The Fibonacci-prime number
2+
Given a number N, the task is to find if N is Fibonacci-prime number or not. A Fibonacci-prime is any number that is both a prime and a Fibonacci number. [🔗Goto](https://practice.geeksforgeeks.org/problems/the-fibonacci-prime-number1150/1/?page=4&difficulty[]=1&status[]=unsolved&category[]=Arrays&category[]=Strings&sortBy=accuracy#)
3+
4+
**Example 1:**
5+
6+
><p>Input: N = "5"<br>
7+
>Output: 1<br>
8+
>Explanation: 5 is a Fibonacci number and prime too</p>
9+
10+
<details>
11+
<summary>Full Code</summary>
12+
13+
```java
14+
import java.io.*;
15+
import java.util.*;
16+
17+
class GFG {
18+
public static void main(String args[]) throws IOException {
19+
BufferedReader read =
20+
new BufferedReader(new InputStreamReader(System.in));
21+
int t = Integer.parseInt(read.readLine());
22+
while (t-- > 0) {
23+
String input = read.readLine();
24+
25+
Solution ob = new Solution();
26+
int result = ob.fibonacciPrime(input);
27+
28+
System.out.println(result);
29+
}
30+
}
31+
}
32+
```
33+
</details>
34+
35+
```java
36+
class Solution {
37+
int fibonacciPrime(String N) {
38+
ArrayList<String> list =new ArrayList<String>();
39+
list.add("2");
40+
list.add("3");
41+
list.add("5");
42+
list.add("13");
43+
list.add("89");
44+
list.add("233");
45+
list.add("1597");
46+
list.add("28657");
47+
list.add("514229");
48+
list.add("433494437");
49+
list.add("2971215073");
50+
list.add("99194853094755497");
51+
list.add("1066340417491710595814572169");
52+
list.add("19134702400093278081449423917");
53+
list.add("475420437734698220747368027166749382927701417016557193662268716376935476241");
54+
for(int i = 0;i<list.size();i++){
55+
if(N.equals(list.get(i)))
56+
return 1;
57+
}
58+
return 0;
59+
}
60+
}
61+
```

0 commit comments

Comments
 (0)