Problem

From wiki.ucalgary.ca
Jump to: navigation, search

1. Write a funtion calculate(). This function will call the following three functions, a. areaCircle(r), takes as input the radius of a circle and returns its area b. areaSquare(a), takes as input the length of one side of a square and returns its area c. areaRectangle(h,w), takes as input height and width of a rectangle and returns its area The calculate() function will then print the area of circle, square and rectangle

2. Fibonacci number is a series like the following, 1, 1, 2, 3, 5, 8

  Write a function fibonacci(n), that will print out n-number of fibonacci number. the output will look    like    the following,
  
  >>fibonacci(4)
  >>1, 1, 2, 3,

3. Write a function draw(width, height). This function will take as input width and height of a rectangle and draw a rectangle using "*". The output will look like the following,

  >>draw(5,3)
  >>*****
    *****
    *****

4. Write a function prime(n), that will take a number as input and print out whether the number is prime or not.