Professional Documents
Culture Documents
Name: Mohammed Alquraish: What The Question Is Asking
Name: Mohammed Alquraish: What The Question Is Asking
Name: Mohammed Alquraish: What The Question Is Asking
Write a Program to print 1st 40 Fibonacci numbers & print numbers that are
divisible by 5 and 7?
REFERENCE:
https://www.mathsisfun.com/numbers/fibonacci-sequence.html
I observe that this series is working on some formula then I searched and I tried to
make it.
A number adds with previous number which is a number before that like:
Code:
import java.awt.*;
import java.util.ArrayList;
}
}
}
Output:
DISCUSSION OF SOLUTION:
Here I made formula and also made list for storing number of Fiboacci series to
find or to check which numbers are divisible by 5 and 7.
Sign of %MOD use to check remainder, to declare list type I searched on net so for
‘int’ wo write ‘Integer’ to declare its type, used ‘t’ as temporary variable to store
current value of array/list like ‘arr.get(i)’ here ‘i’ is used for index number to get
value of that index & get is built-in function of list. And arr.add(i-1, ans) I used ‘i-
1’ because I started loop from ‘1’ and array/list started index is ‘0’ so ‘1-1 = 0’ and
its index number of array/list to where to store and ‘ans’ is variable used for
Fibonacci Series. And then I did swapping to change value of variable ‘ans’ and
did addition for formula in variable ‘add’.