File: my_case.cpp

package info (click to toggle)
skypat 3.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 664 kB
  • sloc: cpp: 2,545; makefile: 220; ansic: 78; sh: 67
file content (36 lines) | stat: -rw-r--r-- 900 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
//===- my_case.cpp --------------------------------------------------------===//
//
//                              The pat Team 
//
// This file is distributed under the New BSD License.
// See LICENSE for details.
//
//===----------------------------------------------------------------------===//
//
// A sample program demonstrating using "pat" performance testing framework.
//
// Author: Luba Tang <luba@skymizer.com>
//===----------------------------------------------------------------------===//
#include "my_case.h"

// Returns the Nth fibonacci number. For negative n, fibonacci(n) is defined to
// be 1.
int fibonacci(int n)
{
  if (n <= 1)
    return 1;

  if (n == 2)
    return 2;

  return fibonacci(n-1) + fibonacci(n-2);
}

// Returns n! (the factorial of n). For negative n, n! is defined to be 1.
int factorial(int n)
{
  if (n <= 1)
    return 1;

  return n * factorial(n-1);
}