1 /******************************************************************************
2 *
3 * Copyright (C) 2005, The Gentee Group. All rights reserved.
4 * This file is part of the Gentee open source project - http://www.gentee.com.
5 *
6 * THIS FILE IS PROVIDED UNDER THE TERMS OF THE GENTEE LICENSE ("AGREEMENT").
7 * ANY USE, REPRODUCTION OR DISTRIBUTION OF THIS FILE CONSTITUTES RECIPIENTS
8 * ACCEPTANCE OF THE AGREEMENT.
9 *
10 * ID: factorial 17.10.06 0.0.A.
11 *
12 * Author: Alexey Krivonogov ( gentee )
13 *
14 ******************************************************************************/
15
16 func uint factorial( uint n )
17 {
18 if n < 3 : return n
19 return n * factorial( n - 1 )
20 }
21
22 func main<main>
23 {
24 uint n
25
26 print("This program calculates n! ( 1 * 2 *...* n ) for n from 1 to 12\n\n")
27
28 fornum n = 1, 13
29 {
30 print("\(n)! = \( factorial( n ))\n")
31 }
32 getch()
33 }
34
Редактировать