how can we write a fibunacci sequance less than 1000 in java? | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

how can we write a fibunacci sequance less than 1000 in java?

30th Oct 2019, 6:45 PM
Amir allameh
Amir allameh - avatar
9 Answers
+ 4
by first learning how to code and then writing the code to output all fibonacci lower than 1000
30th Oct 2019, 6:47 PM
Brave Tea
Brave Tea - avatar
+ 2
if you are asking what the code should look like I’d say: please upload what you have tried thusfar so we can help you out with the code. #notdoingyourhomeworkforyou
30th Oct 2019, 6:50 PM
Brave Tea
Brave Tea - avatar
+ 1
No Problem!
30th Oct 2019, 7:21 PM
Alek Sei
Alek Sei - avatar
+ 1
There are several ways to write fibonacci: iteratively, recursively, dynami programming. Which one are you referring to? anyways it is a good way to learn the differernt types f algorithms so learn em all.
1st Nov 2019, 7:05 AM
Logomonic Learning
Logomonic Learning - avatar
0
Fibonacci sequence goes in a way, when the sum of pervious two numbers becomes a new number, first numbers of Fibo are 0 and 1, so the sequance goes as 0, 1, 1, 2, 3, 5, 8... All you have to do is make a method, which would sum up previous numbers and add use them as a new number in the sequence.... how about a LOOP? ;)
30th Oct 2019, 7:00 PM
Alek Sei
Alek Sei - avatar
0
public class fibunacci { public static void main(String[] args) { static long fib(int n) if (n<=1){ return n; else return fib (n-1)+(n_2); } System.out.println(""); i dont know how to add lower 1000 with a loop. }
30th Oct 2019, 7:05 PM
Amir allameh
Amir allameh - avatar
0
Have you learned about While and For loops? Both would allow you to achieve the requirements, although I personally would go with WHILE, so it would start with a condition, E.G. while (maxNumber **** 1000) - replace **** with what would meet the criteria of your requirement and then proceed to create the loop. Right here in Solo, we have a good section about htose loops in Java.
30th Oct 2019, 7:14 PM
Alek Sei
Alek Sei - avatar
0
tnx bro
30th Oct 2019, 7:17 PM
Amir allameh
Amir allameh - avatar
- 1
🤨🤨🤨
30th Oct 2019, 6:48 PM
Amir allameh
Amir allameh - avatar