Question
Java please
. Write an array that contains the first 30 Fibonacci numbers as discussed in class. Compute the numbers, except for the first two.
media%2Fa37%2Fa373d83e-6186-4769-b861-8c
0 0
Add a comment Improve this question Transcribed image text
Answer #1
import java.util.Arrays;

public class FibonacciArray {

    public static void main(String[] args) {
        int[] arr = new int[30];
        arr[0] = 0;
        arr[1] = 1;
        for(int i = 2; i < arr.length; ++i) {
            arr[i] = arr[i-1] + arr[i-2];
        }
        System.out.println("Fibonacci array is: " + Arrays.toString(arr));
    }

}

Add a comment
Know the answer?
Add Answer to:
Java please . Write an array that contains the first 30 Fibonacci numbers as discussed in...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a Java program that generates an array of Fibonacci numbers. Specifications: The program -Fills a...

    Write a Java program that generates an array of Fibonacci numbers. Specifications: The program -Fills a one-dimensional array with the first 30 Fibonacci numbers using a calculation to generate the numbers. Note: The first two Fibonacci numbers 0 and 1 should be generated explicitly as in -long[] series = new long[limit]; //create first 2 series elements series[0] = 0; series[1] = 1; -But, it is not permissible to fill the array explicitly with the Fibonacci series’ after the first two...

  • Finish the Fibonacci problem in Program Challenge 6 by using array. First you need to store...

    Finish the Fibonacci problem in Program Challenge 6 by using array. First you need to store the calculated Fibonacci numbers in an array. And finally print out those numbers by reading through the array. Please name your program as HW4.j. And remember to write some comments in your program. The pseudo code written in Java could be like below:

  • Fibonacci numbers – for loops We’ll define the Fibonacci numbers to be an integer sequence starting...

    Fibonacci numbers – for loops We’ll define the Fibonacci numbers to be an integer sequence starting with 1, 1, and where each subsequent element is got by adding the previous two elements: 1, 1, 2, 3, 5, 8, . . . (Mathematicians start with 0, 1, . . . , but we want to avoid zeros because you can’t take their log. ) Write a python programme in a Jupyter notebook which uses a for-loop to fill an array with...

  • Use a for loop in Matlab to create an array containing the first 1,000 Fibonacci numbers....

    Use a for loop in Matlab to create an array containing the first 1,000 Fibonacci numbers. Then determine how many of those numbers are divisible by 3.

  • in java please Write a program that contains an array with all of your friends' first...

    in java please Write a program that contains an array with all of your friends' first names. Enter the values in any manner and order you choose (I recommend favorites first). Now take that array and sort it alphabetically so that names that start with ‘A' c me first. Look to see if you have any duplicates and if you find any, print out their names. You may use a binary search to determine this. 2. Sample output: Input list...

  • Using JAVA, write an application that uses an Array of 30 Numbers (random integers from 1...

    Using JAVA, write an application that uses an Array of 30 Numbers (random integers from 1 - 100) and returns the maximum number, minimum number, average of all numbers, and prints a Bar Chart to show the number distribution (1-9, 10-19,20-29, …80-89, 90-100). Note; maximum number, minimum number, average number, and the Bar Chart must use implemented as separate methods in a separate class. Method call should pass an array as an argument. Methods should accept an array as an...

  • The Lucas Numbers are a sequence very similar to the Fibonacci sequence discussed in class, the...

    The Lucas Numbers are a sequence very similar to the Fibonacci sequence discussed in class, the only difference being that the Lucas Numbers start with 10-2 L,-1 as opposed to Fibonacci's Fo = 0 and F1 = 1, concretely, they are defined by Lo = 2, L,-1 and Ln-Ln-l + Ln-2 for n > 1 Write a Python function called first D_digit Lucas that takes an integer argument D less than 30 and returns the first D-digit Lucas number. For...

  • Please I need java code for this question with output: 4.19) The Fibonacci sequence is the...

    Please I need java code for this question with output: 4.19) The Fibonacci sequence is the series of numbers 0, 1, 1, 2, 3, 5, 8, .... Formally, it can be expressed as: f ib0 = 0 f ib1 = 1 f ibn = f ibn−1 + f ibn−2 Write a multithreaded program that generates the Fibonacci sequence using either the Java, Pthreads, or Win32 thread library. This program should work as follows: The user will enter on the command...

  • 3[20%] | Fibonacci numbers are the numbers in a sequence in which the first two ele-...

    3[20%] | Fibonacci numbers are the numbers in a sequence in which the first two ele- ments are 0 and 1, and the value of each subsequent element is the sum of the previous two elements: 0,,,2,3, 5, 8, 13, Write a MATLAB program in a script file that determines and displays the first 20 Fibonacci numbers.

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT