<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Return values fibonacci series java in Developers Questions</title>
    <link>https://community.esri.com/t5/developers-questions/return-values-fibonacci-series-java/m-p/1269693#M6533</link>
    <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/648697"&gt;@hectorsalamanca&lt;/a&gt;&amp;nbsp;somewhere you need to call the function buildArray(), like&lt;/P&gt;&lt;PRE&gt; long A[] = buildArray();&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;also note you don't need either parameter, the way you designed the code they aren't necessary.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Mon, 20 Mar 2023 23:12:04 GMT</pubDate>
    <dc:creator>John-Foster</dc:creator>
    <dc:date>2023-03-20T23:12:04Z</dc:date>
    <item>
      <title>Return values fibonacci series java</title>
      <link>https://community.esri.com/t5/developers-questions/return-values-fibonacci-series-java/m-p/1261365#M6505</link>
      <description>&lt;P&gt;I'm attempting to recursively calculate the fibonacci sequence to 100, save the resulting values in an array using the buildArray function, and then display the array contents.&lt;/P&gt;
&lt;P&gt;here is the code:&lt;/P&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;LI-CODE lang="java"&gt;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 &amp;lt; 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 &amp;lt; MAX; N++)
            System.out.println(N + " " + A[N]);
    }
}&lt;/LI-CODE&gt;
&lt;P&gt;&amp;nbsp;&lt;/P&gt;
&lt;P&gt;When I try to print A[N] in the main method, I receive a "cannot be resolved to a variable" compilation error. I'm using longs&amp;nbsp;and I'm computing the series up to 100, however I'm not sure if longs are required.&lt;/P&gt;
&lt;P&gt;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? I'm just getting started with Java.&lt;BR /&gt;Thanks.&lt;/P&gt;</description>
      <pubDate>Wed, 13 Dec 2023 14:24:36 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/return-values-fibonacci-series-java/m-p/1261365#M6505</guid>
      <dc:creator>hectorsalamanca</dc:creator>
      <dc:date>2023-12-13T14:24:36Z</dc:date>
    </item>
    <item>
      <title>Re: Return values fibonacci series java</title>
      <link>https://community.esri.com/t5/developers-questions/return-values-fibonacci-series-java/m-p/1269693#M6533</link>
      <description>&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/648697"&gt;@hectorsalamanca&lt;/a&gt;&amp;nbsp;somewhere you need to call the function buildArray(), like&lt;/P&gt;&lt;PRE&gt; long A[] = buildArray();&lt;/PRE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;also note you don't need either parameter, the way you designed the code they aren't necessary.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 20 Mar 2023 23:12:04 GMT</pubDate>
      <guid>https://community.esri.com/t5/developers-questions/return-values-fibonacci-series-java/m-p/1269693#M6533</guid>
      <dc:creator>John-Foster</dc:creator>
      <dc:date>2023-03-20T23:12:04Z</dc:date>
    </item>
  </channel>
</rss>

