-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #169 from VishweshPatel/VishweshPatel
Added new file
- Loading branch information
Showing
2 changed files
with
34 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
28 changes: 28 additions & 0 deletions
28
Program's_Contributed_By_Contributors/Java_Programs/Finobbaci.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import java.util.*; | ||
class fibo | ||
{ | ||
public static void main(String args[]) | ||
{ | ||
Scanner sc = new Scanner(System.in); | ||
int n, sum, a = 1, b = 1, flag; | ||
n = sc.nextInt(); | ||
System.out.print(a+" "+b); | ||
for (int i = 2; i < n; i++) { | ||
flag = 0; | ||
sum = a+b; | ||
if (sum%5==0) System.out.print("0 "); | ||
else { | ||
for (int j = 2; j < sum/2; j++) { | ||
if (sum % j == 0) { | ||
System.out.print(sum+" "); | ||
flag = 1; | ||
break; | ||
} | ||
} | ||
if (flag == 0) System.out.print("0 "); | ||
} | ||
a = b; | ||
b = sum; | ||
} | ||
} | ||
} |