/* ==================================================================== */ /* FIBONACCI_CLASS.C */ /* */ /* -------------------------------------------------------------------- */ /*************************************************************************** * * Copyright (c) 1989, 1990, 1991, 1992, 1993 * Rector and Visitors of the University of Virginia * All Rights Reserved * * This file is part of the Mentat system software library. This software * is intended for research and is available free of charge for that * purpose; however, all material is the proprietary source of the * University of Virginia, and may not be disclosed or copied in any * form without the explicit written permission of the Univeristy of * Virginia. * * This software is distributed WITHOUT ANY WARRANTY; without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. This software hereunder is provided on an "as is" basis, * and the University of Virginia has no obligation to provide maintenance, * support, updates, enhancements, or modifications. * * Send problems & suggestions to: * mentat@Virginia.EDU * ***************************************************************************/ /*-------------------------------------------------------------------------- * * The purpose of this class is to demonstrate the use of regular * Mentat classes and rtf. * * Note: This is an example only, it is too fine-grained. This * is not an efficient implementation of fibonacci, it is for * illustrative purposes only. * *------------------------------------------------------------------------*/ #include "adder_class.h" #include "fibonacci_class.h" int fibonacci_class::fibonacci(int n) { fibonacci_class fib; adder_class adder; if (n == 0 || n == 1) rtf(1); else { rtf(adder.add(fib.fibonacci(n - 1), fib.fibonacci(n - 2))); } return(1); }