It looks like you're using an Ad Blocker.
Please white-list or disable AboveTopSecret.com in your ad-blocking tool.
Thank you.
Some features of ATS will be disabled while you continue to use an ad-blocker.
public class MyFibonacci [
public static final int MAX = 100;
public static long[] buildArray(int MAX, int N) [
long[] A = new long[MAX];
A[0] = 0;
A[1] = 1;
for(N = 2; N < MAX; N++)
A[N] = F(N);
return A;
]
public static long F(int N) [
if(N == 0)
return 0;
if(N == 1)
return 1;
return F(N - 1) + F(N - 2);
]
public static void main(String[] args) [
for(int N = 0; N < MAX; N++)
System.out.println(N + " " + A[N]);
]
]
originally posted by: Mobo01
The code works if I replace F(N) for A[N], but I need to put the data into an array and output that array. Is it even possible for this code to save the data in an array? Thank you; I'm just getting started with Java.