+ 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; } } }
15 Réponses
+ 3
Thanks a lot for the help Thomas and Arrie
+ 2
Show your attempt
+ 2
I tried this....but didn't work
+ 2
Thanks Arrie, but is there anything simpler? I am just a beginner
+ 2
Can someone pls say wts wrong with my prgrm
+ 2
Link the actual program I mean. So we can change things in the code and view errors
+ 2
How to link a program?
+ 2
Little green plus-sign next to the text box (in front of you)
+ 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;
}
}
}
+ 2
Yeah just checked it out in your profile. You should use regular ASCII-quotations signs. " " and not ` `
+ 2
Ill see if I can get your sequencing right
+ 2
Thomas, I used " ". I did not use ' '.
+ 1
You can use this formula:
an = (Phi ^ n - (phi ^ n))/√5
Where Phi = (1 + √5) / 2 and
phi = (1 - √5) / 2
+ 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