delgal01na

Untitled

Jul 11th, 2017
28
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.42 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3.  
  4. public class Day1Java {
  5.  
  6. int fibb(int a,int b) {
  7. for(int i=0;i<no;i++){
  8. int c=a+b;
  9. a=b;
  10. b=c;
  11. return(c);
  12. }
  13. }
  14.  
  15. public static void main(String[] args) {
  16. Scanner sc=new Scanner(System.in);
  17. System.out.println("enter number of terms: ");
  18. int no=sc.nextInt();
  19. int a=0,b=1,c;
  20. Day1Java day1Java=new Day1Java();
  21. day1Java.fibb(a,b);
  22. sc.close();
  23. }
  24. }
Add Comment
Please, Sign In to add comment