Determining whether a number is a Fibonacci number

前端 未结 14 1336
暗喜
暗喜 2021-01-18 05:35

I need to to write a Java code that checks whether the user inputed number is in the Fibonacci sequence.

I have no issue writing the Fibonacci sequence to output, b

14条回答
  •  甜味超标
    2021-01-18 06:37

    Consider the sequence of Fibonacci numbers 1,1,2,3,5,8,13,21, etc. It is desired to build 3 stacks each of capacity 10 containing numbers from the above sequences as follows:

    Stack 1: First 10 numbers from the sequence. Stack 2: First 10 prime numbers from the sequence. Stack 3: First 10 non-prime numbers from the sequence.

    (i) Give an algorithm of the flowchart (ii) Write a program (in BASIC, C++ or Java) to implement this.

    Output:As stack operations take place you should display in any convenient form the 3 stacks together with the values held in them.

提交回复
热议问题