+ 1

How to find fibonacci numbers using java?

class Q1c { public static void main (String s[]) { int i, a=0,b=1,c=2,d; System.out.print(a+”,”); System.out.print(b+”,”); System.out.print(c+”,”); for(i=4;i<=10;i++) { d=a+b+c; System.out.print(d+”,”); a=b; b=c; c=d; } } }

15th Jun 2019, 4:47 PM
Marianna
15 Réponses
+ 3
Thanks a lot for the help Thomas and Arrie
15th Jun 2019, 5:15 PM
Marianna
+ 2
Show your attempt
15th Jun 2019, 4:48 PM
Trigger
Trigger - avatar
+ 2
I tried this....but didn't work
15th Jun 2019, 4:53 PM
Marianna
+ 2
Thanks Arrie, but is there anything simpler? I am just a beginner
15th Jun 2019, 5:02 PM
Marianna
+ 2
Can someone pls say wts wrong with my prgrm
15th Jun 2019, 5:02 PM
Marianna
+ 2
Link the actual program I mean. So we can change things in the code and view errors
15th Jun 2019, 5:03 PM
Trigger
Trigger - avatar
+ 2
How to link a program?
15th Jun 2019, 5:04 PM
Marianna
+ 2
Little green plus-sign next to the text box (in front of you)
15th Jun 2019, 5:06 PM
Trigger
Trigger - avatar
+ 2
class Q1c { public static void main (String s[]) { int i, a=0,b=1,c=2,d; System.out.print(a+”,”); System.out.print(b+”,”); System.out.print(c+”,”); for(i=4;i<=10;i++) { d=a+b+c; System.out.print(d+”,”); a=b; b=c; c=d; } } }
15th Jun 2019, 5:06 PM
Marianna
+ 2
Yeah just checked it out in your profile. You should use regular ASCII-quotations signs. " " and not ` `
15th Jun 2019, 5:08 PM
Trigger
Trigger - avatar
+ 2
Ill see if I can get your sequencing right
15th Jun 2019, 5:08 PM
Trigger
Trigger - avatar
+ 2
Thomas, I used " ". I did not use ' '.
15th Jun 2019, 5:10 PM
Marianna
15th Jun 2019, 5:10 PM
Trigger
Trigger - avatar
+ 1
You can use this formula: an = (Phi ^ n - (phi ^ n))/√5 Where Phi = (1 + √5) / 2 and phi = (1 - √5) / 2
15th Jun 2019, 5:00 PM
Airree
Airree - avatar
+ 1
I made a demo with recursive functions. This is literally the way to count it: an = an-1 + an-2 https://code.sololearn.com/cW0P1OKRjG91/?ref=app
15th Jun 2019, 5:14 PM
Airree
Airree - avatar