#!/usr/bin/perl

$mode = "M";

for ($input = 0; $input <= 100; $input++)
	{
	if ($mode eq "G")
		{
		print "G($input) = ", &G($input), "\n";
		}
	elsif ($mode eq "F")
		{
		print "F($input) = ", &F($input), "\n";
		}
	elsif ($mode eq "M")
		{
		print "M($input) = ", &M($input), "\n";
		}
	}


sub F
	{
	my $n = $_[0];
	if ($n == 0) {$n = 1} else {$n = $n - &M(&F($n-1))}
	$n;
	}

sub M
	{
	my $n = $_[0];
	if ($n == 0) {$n = 0} else {$n = $n - &F(&M($n-1))}
	$n;
	}


sub G
	{
	my $n = $_[0];
	if ($n == 0) {$n = 0} elsif ($n > 0) {$n = $n - (&G(&G($n-1)))}
	}
