Java Forums

Main Menu
Home
Today's Posts
FAQ
Search
Contact Us

Java Network
Java Tips
Java Tips Blog

Sponsored Links





Welcome to the Java Forums.

You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community, you will:

  • have access to post topics
  • communicate privately with other members (PM)
  • not see advertisements between posts
  • have the possibility to earn one of our surprises if you are an active member
  • access many other special features that will be introduced later.

Registration is fast, simple and absolutely free so please, join our community today!

If you have any problems with the registration process or your account login, please contact us.

Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-29-2008, 09:29 AM
Member
 
Join Date: Mar 2008
Posts: 1
andrew777 is on a distinguished road
Help With Recursion
Hi there,
Im trying to write a method that takes in an int, and counts all the binary numbers up to that length, and prints them one by one. For example, 3 would give:

001
010
011
100
101
110
111

And have come up with something really messy with a whole lot of while loops that doesnt quite work.

I know there must be a simpler way to do it recursively but i cant quite wrap my head around how. Can anyone help?

Thanks a lot
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
  #2 (permalink)  
Old 03-29-2008, 01:51 PM
CaptainMorgan's Avatar
Moderator
 
Join Date: Dec 2007
Location: NewEngland, US
Posts: 840
CaptainMorgan will become famous soon enoughCaptainMorgan will become famous soon enough
Send a message via AIM to CaptainMorgan
Let's see your code. I'm particularly interested in seeing the printing function for outputting binary numbers where from we can then begin to think about making it recursive.

Please post the whole code and be sure to use surrounding [ code] tags.

Oh, and welcome to the Java Forums!
__________________

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
to our beloved Java Forums!
(closes on September 4, 2008)
Want to voice your opinion on your IDE/Editor of choice?
To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.
!
Got a little Capt'n in you? (drink responsibly)
Bookmark Post in Technorati
Reply With Quote
Sponsored Links
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
recursion kdeighan New To Java 3 01-25-2008 10:48 PM
Recursion bozovilla Advanced Java 3 01-07-2008 05:53 PM
recursion ravian New To Java 2 12-03-2007 06:15 PM
Help with recursion scts102 New To Java 1 11-19-2007 11:07 PM
Recursion in java lenny Advanced Java 1 08-07-2007 07:23 AM


All times are GMT +3. The time now is 09:24 PM.


VBulletin, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Content Relevant URLs by vBSEO ©2007, Crawlability, Inc.
Copyright ©2006 - 2007, www.java-forums.org