Important News

We have released Shinobi Life Online Pre-Alpha Version 1.1.0.0! This update features Earth Release: Earth Dome Jutsu, Aiming Mode and more! Try it out and tell us what you think.

User

Welcome, Guest.
Please login or register.
 
 
 
Forgot your password?

Discord

Statistics

Members
Total Members: 55954
Latest: wexaso4071
New This Month: 1
New This Week: 3
New Today: 1
Stats
Total Posts: 55780
Total Topics: 3340
Most Online Today: 1410
Most Online Ever: 4232
(January 14, 2020, 07:47:33)
Users Online
Members: 1
Guests: 1117
Total: 1128
MaybellSto
Google (10)

Author Topic: Recursion Program.  (Read 11854 times)

0 Members and 1 Guest are viewing this topic.

Offline Kakashi Natsu

  • Chunin Poster
  • ***
  • Posts: 141
  • Reputation Power: 2
  • Kakashi Natsu has no influence.
  • Gender: Male
  • Give up trying to make me give up.
    • View Profile
  • Clan: Agni
Recursion Program.
« on: March 25, 2017, 02:56:41 »
So a friend asked me to help him with a program using Java. SO being a good friend, i did. Unknowingly i got myself into a heap of trouble... getting into recursion. Now for some of you, you may not know what recursion is in programming. Well here is an example of a factorial.
[/size]
[/size]
Code: [Select]





//will return an integer
number = 0;


Integer factorial(integer n){
if(n==0){
return number
}
number = n*factorial(n-1)




}
//lets call up this routine
factorial(3)
//this is 6 btw.



[/size]
[/size]So This is a simple version of a recursive program, where in the program itself, it calls itself up. Confusing but very helpful when it comes to path finding. For those that have a JDK and can run Java. To see the program i helped my friend with, click on the zip folder->https://jetfire3201.000webhostapp.com/ and run it in netbeans or eclipse. Main program is in Easterbunny.java.



Offline ThatsHawt

  • Academy Student Poster
  • *
  • Posts: 1
  • Reputation Power: 2
  • ThatsHawt has no influence.
  • Gender: Male
  • I'm new around here.
    • View Profile
Re: Recursion Program.
« Reply #1 on: October 01, 2017, 06:22:40 »
in your factorial method, you should return an int instead of an Integer.
Every time you run this method it creates an Integer object which is a waste of space when you can just return an int.
  • Character Name: Hawt

 

Recent Topics

Dev Blog 8 - March 7th 2017 by Maxxx001
March 28, 2025, 21:24:39

WARNING! MANGA LAST PAGE! Naruto 698. by sussie
March 27, 2025, 12:12:30

Buy Waklert 150: A Comprehensive Solution to Stay Energized|cheaptrustedpharmacy by ameliasmith
March 24, 2025, 06:44:10

Shinobi Life Online - Updated Combat Test - 17/02/2025 by mamita
March 07, 2025, 12:55:46

Koryuu Clan by mamita
February 21, 2025, 06:35:26

Zeimatsu Clan (UPDATED OVERALL 3) by mamita
February 21, 2025, 06:31:31

Nogitsu Clan by mamita
February 21, 2025, 06:27:59

Yoshizaki Clan by mamita
February 21, 2025, 06:26:01

The Chiitsuki Clan by mamita
February 21, 2025, 06:20:54

OdiloShinnai by mamita
February 21, 2025, 06:15:18

Top Posters

Mars
Posts: 2638
Reminance
Posts: 2233
Shivraj
Posts: 1610
m4r1us
Posts: 1298
Manuster
Posts: 1267
NinjaMirage
Posts: 1165
Nova
Posts: 1140
taigakun
Posts: 1094
Fraudulent
Posts: 1086
Konohuro
Posts: 1056