Answer to Question #349448 in Java | JSP | JSF for Chandrika

Question #349448

Fibonacci sequence




1
Expert's answer
2022-06-13T08:29:05-0400
public class Fibonachi {
    public static void printFibonachi(int n) {
        int cur = 0;
        int next = 1;
        for (int i = 0; i < n; i++) {
            System.out.print(cur + " ");
            int tmp = next;
            next += cur;
            cur = tmp;
        }
        System.out.println();
    }
    public static void main(String[] args) {
        int n = Integer.parseInt(args[0]);
        printFibonachi(n);
    }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS