**Pagini **

# Workshops

**Parteneri**

In this lab, you get familiar with the basic Scala syntax and functionality.

You'll quickly get up to speed by solving some classical programming problems.

You can find today's contents here.

You can create a simple project, with a single Scala file. Call it whatever you like.

Along with the *main* method, you can create a method for every exercise.

**Fibonacci**- write a function that computes the nth Fibonacci number.- write the signature of the method first and follow the syntax
def methodName(param: ParamType, param: ParamType): ReturnType = { // code }

- this should be a simple recursive function

**is it prime**- write a function which tests if an integer is prime.- again, define the signature first
- you might want to define an auxiliary function
- you can do this
*inside*the method implementation

**sum of powers**- implement a function which computes a sum of powers for the numbers 1 to n- pay special attention to signature - you can make this very generic if you like

**@tailrec**- rewrite a recursive function to be tail-recursive- follow our instructions on which function to rewrite and how to do this
- you can
*probably*rewrite one of the earlier functions to be @tailrec (wink)