answersLogoWhite

0

// recursive implementation of factorial function

long factorial(const int n) {

if(n <= 1) {

return 1L;

}

return n * factorial(n-1);

}

@echo off

echo RECURSE.BAT

echo This demonstrates recursion

echo To run this, save this into a document on your desktop named RECURSE.BAT then double click

call :func 5

echo All done.

pause

goto :eof

rem Functions begin here

:func

rem Variables in this language are globally scoped. SETLOCAL makes the variable scope local.

setlocal

set /a nextlevel=%1 - 1

echo Start Level=%1 - Next level=

rem Here is our recursive call. Note that we only call recursively if the next level is greater than or equal to 1

ifgeq 1 call :func

echo End Level=%1

endlocal

goto :eof

User Avatar

Wiki User

16y ago

What else can I help you with?

Related Questions

How do you write a program using 57252077?

Please be more explicit, 57252077 is a bit of a mystery. Do you want a program that uses the number 57252077 in some way?


How can I write a program to display prime numbers from 1 to 100?

Write a function that implements an algorithm that checks to see if a particular integer is prime (returning a boolean). Write a program that uses that function on each number from 1 to 100, and if true, displays that number.


Write a C program to implement excelp system call?

You are not able to do that, but you can write a program, that uses the system-call./* exectest.c */#include int main (void){execlp ("/bin/ls", "ls", "-ld", ".", NULL);return 0;}


How do you spell employ?

That is the correct spelling of employs (hires workers, or uses).


Who execute a program?

Anobody who uses it is said to "execute" or "run" the program.Anobody who uses it is said to "execute" or "run" the program.Anobody who uses it is said to "execute" or "run" the program.Anobody who uses it is said to "execute" or "run" the program.


What is a lighting device which employs the uses methylated or volatile fuels such as alcohol instead of oil called?

spirit lamp


What kind of program uses a large system cache?

What kind of computer program uses a large system cache?


HTML code has a limit of 10 webpages per site?

No! HTML is simply code. You can write 1 million pages of HTML code if you want. HTML is not a program. Its code. Now you may have a program that uses HTML code and that program has limitations. But not HTML itself.


What kind of encryption uses the concept of public keys?

Asymmetric encryption employs the use of public/private key pairs.


A C program using dynamic memory allocation to sort n names in ascending order?

Writing a C program that uses dynamic memory allocation to sort names in ascending order is a typical computer science assignment. To write this program, you must be in UNIX.


What program does the tubbylife use?

The tubbylife uses the program FL Studio 10.


Does she have msn?

It depends on what IM program she uses. If she uses MSN Messenger then the answer is yes.