forked from twowaits/make-pull-request
-
Notifications
You must be signed in to change notification settings - Fork 0
/
1stOct_rushikeahadhav.java
42 lines (40 loc) · 953 Bytes
/
1stOct_rushikeahadhav.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
package com.company;
import java.util.Scanner;
public class fib {
public static void main(String[] args) {
Scanner in = new Scanner(System.in);
int n = in.nextInt();
fib(n);
}
static void fib(int n){
int a = 0;
int b = 1;
int c;
System.out.println(a + " ");
for(int i = 0; i<n; i++){
boolean p = primeN(b);
if(p == true || b % 5 == 0){
System.out.println(0);
c = a + b;
a = b;
b = c;
continue;
}
System.out.println(b + " ");
c = a + b;
a = b;
b = c;
}
}
static boolean primeN(int n){
if(n == 1){
return false;
}
for(int i=2; i<=Math.sqrt(n); i++){
if(n % i == 0){
return false;
}
}
return true;
}
}