0% found this document useful (0 votes)
15 views1 page

Fibonacci Series Java

This Java code defines a Fibonacci class with a main method that uses a for loop to print out the first 10 terms of the Fibonacci series by initializing the first two terms and then calculating each subsequent term as the sum of the previous two terms.

Uploaded by

factology10m
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views1 page

Fibonacci Series Java

This Java code defines a Fibonacci class with a main method that uses a for loop to print out the first 10 terms of the Fibonacci series by initializing the first two terms and then calculating each subsequent term as the sum of the previous two terms.

Uploaded by

factology10m
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 1

Fibonacci Series in Java

public class Fibonacci {

public static void main(String[] args) {

int n = 10; // Number of terms in the Fibonacci series

int firstTerm = 0, secondTerm = 1;

System.out.println("Fibonacci Series till " + n + " terms:");

for (int i = 1; i <= n; ++i) {

System.out.print(firstTerm + ", ");

// Compute the next term

int nextTerm = firstTerm + secondTerm;

firstTerm = secondTerm;

secondTerm = nextTerm;

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy