-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathFibonacci_2D.java
56 lines (47 loc) · 1.51 KB
/
Fibonacci_2D.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import java.io.*;
public class Fibonacci_2D
{
public static void main (String args[]) throws IOException{
BufferedReader br=new BufferedReader (new InputStreamReader (System.in));
System.out.println("Enter the row and column respectively");
int m=Integer.parseInt (br.readLine());
int n=Integer.parseInt (br.readLine());
int f=m*n;
int arr[][]=new int [m][n];
int a1[]=new int [f];
int i=0;
int j=1;
a1[0]=i;
a1[1]=j;
int k=0;
int pos=2;
while (k!=(f-2)){
int c=i+j;
a1[pos]=c;
pos++;
i=j;
j=c;
k++;
}
pos=0;
for (i=0;i<m;i++){
for (j=0;j<n;j++){
arr[i][j]=a1[pos];
pos++;
}
}
for (i=0;i<m;i++){
for (j=0;j<n;j++){
System.out.print(arr[i][j]+"\t");
}
System.out.println();
}
}
}
👋 Hi, I’m @aarushinair - Aarushi Nair (she/her/ella)
👀 I’m a Computer Science Engineering Student
💞️ I’m looking to collaborate on #java, #python, #R, #applicationdevelopment
🌱 #GirlsWhoCode #WomenInTech #WomenInIT #WomenInSTEM #CyberSecurity #QuantumComputing #BlockChain #AI #ML
📫 How to reach me: https://www.linkedin.com/in/aarushinair/
👩🏫 YouTube Channel - Code with Aarushi : https://www.youtube.com/channel/UCKj5T1ELHCmkGKujkpqtl7Q
🙋 Follow me on Twitter: https://twitter.com/aarushinair_