title: Gradle Task - unable to execute fibonacci series in groovy
body: <p>Facing problem in a question:</p>
  
  <p>Write a gradle program to generate 10 fibonaci series, with task name as fibo, and variable name as num. Use command line argument for num.
  For example, if a task name is test and I want to pass 10 as the input, use gradle test -Pnum=10.</p>
  
  <p>I have created a function: </p>
  
  <pre><code>def fibo(n){
      a = 0
      b = 1
      if (n == 1)
      println a
      else if
      (n == 2)
      println a + " " + b
      else if (n &gt; 2) {
          print a + " " + b
          i = 2
          while (i &lt;= n)
          {
          c = a + b
          print " " + c
          a = b
          b = c
          i = i + 1
          }
      }
  }
  </code></pre>
  
  <p>My question is, how to link it with a task as I encounter error like:</p>
  
  <p>FAILURE: Build failed with an exception.</p>
  
  <pre><code>* What went wrong:
  Task 'fibo' not found in root project 'root'.
  
  * Try:
  Run gradle tasks to get a list of available tasks. Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
  
  BUILD FAILED
  
  Total time: 2.61 secs
  </code></pre>
  
  <p>or how to pass parameters in a gradle task?</p>
  
  <p><em>Note: Please do not suggest optimization in fibonacci code, thats not a concern for now.</em></p>