doburomirushii nikku

Ranch Hand
+ Follow
since Oct 06, 2004
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
In last 30 days
0
Forums and Threads

Recent posts by doburomirushii nikku

Yeah I mean log(base 8) 2. Thanks for the reply...I will look that up and see if it helps.

Edit: Figured it out...


[ April 10, 2006: Message edited by: doburomirushii nikku ]
19 years ago
I'm trying to do a recursion that will find log 2^8 and return 3. Also if it gets log 2^15 it should return 3 also (so it rounds it down). Then I want to design a similar recusion method that will only find a perfect log such as log 2^8 = 3, but return -1 for log 2^15.

Here is my code for it.


I know you need a base case for recusion so that would be if the value was 1...then whatever the base is would have to be rasied to the 0 power. Then there is also if base == value...The method would return 1.

But I'm now really sure how my recursion case should go. I understand that what I'm doing is going to do 2, then 2 * 2, then 4 * 4, ect., which is incorrect. So how can I preserve the base value?

I think I want the method to do this:

1 + floorLog(2, 8)
1 + floorLog(2 * 2, 8)
1 + floorlog(2 * 2 * 2, 8)
At this point I want it to return in my base case...I'm just not sure how to translate it recursively.

Thanks.

Edit: I forgot...I need to do it without importing java.math
[ April 10, 2006: Message edited by: doburomirushii nikku ]
19 years ago
I got it to work using your advice.

Talked it through and realized that since the square root of 9 was three it would skip the for loop and denote it as prime. Then I realized like you hinted at, that the for loop had to be inclusive.

Thanks for all the help everyone. The best part is that I really understand how to do this problem now!
19 years ago
Um...I still don't know how to make number go up right...

Here is the code I have now...

19 years ago
Hello,

I have to make a program that finds the nth prime number. Basically, the user types in a number, for example, 10 and the program outputs 29 (the 10th prime number).

I have created my program and I think I must be on the right track since when I input 10 the program outputs 28. The actual output is always a few numbers off the expected output and as you go higher...say you input 12, the program will output 32 as opposed to 37.

I think it is something to do with the way I increment my "number" value and I have played with it to make it go through the numbers as I want but have had no luck.

19 years ago
basically, this program reads a list of numbers from a text file and then takes the factorial of each of those numbers. I got everything to work except the factorials are kinda off. They display the wrong values.

20 years ago


ok so far it draws to cards for the dealer and player and displays the pictures on the applet. Then when i press hit, it will draw a new card, however it wont show the picture. It also displays only pictures of in spade cards. So it may display to 10 of spades when 10 of hearts and 10 or diamonds is drawn from the deck, for some reason. Any help, thank you.
20 years ago
Thanks for anyone who posted!

I really liked how david explained it though, and it was pretty easy. I think im starting to understand arrays better.
20 years ago
this is what i have now



after the first loop runs, i have 4 of every card..but in the second loop somehow im getting duplicates. and card suit is just takin the remainder if its 0 and then that would be one suit, 1, 2, 3 would be the four suits.
20 years ago
ok..this outputs random..but then there is the issue of repeats im stuck on.

20 years ago
eh thank..Is there a way to do it without this though? I'm not really understanding this.
20 years ago
I'm not sure how to use collection..it says varible not found when i put it in.
20 years ago
im trying to deal out a 52 card deck of cards, randomly.. They have their card number and th suit attached to them. Can someone direct me in a better direction..I dont feel like im getting anywhere.


[ November 14, 2004: Message edited by: Kenshin Himura ]
20 years ago
You know..sometimes my head just does not work for programming. Thanks for all your help guys, I got it working. Layne cleared up what the others where trying to get through my thick head hehe . Here's the code if your interested.

20 years ago
Yes..But isn't that what I did in my code? Switched the x and th y around?
20 years ago