# Trying to complete a hailstone app in vb6 and cant...help

Discussion in 'OT Technology' started by quickone, Mar 24, 2005.

1. ### quickoneNew Member

Joined:
Sep 15, 2004
Messages:
4,179
0
here is what im trying to do....the functions are at the very bottom since I had trouble pasting it......
Hailstones

There is an interesting sequence of numbers know as Hailstones. Each number in the sequence is derived from the pervious number by running the previous number through a mathematical function. The series got its name from the fact that the numbers will go up, and then down, then up, and then back down (similar to the way real hailstones are formed in the atmosphere). Eventually the series settles into a steady state of 4, 2, 1, 4, 2, 1, 4, 2, 1 … etc.

The hailstones function is:

If f(i) is even:

If f(i) is even:

If f(i) is odd:

In other words, if you wanted to compute some hailstones, first pick any positive integer to start the sequence. If the number you picked was even, the next number is simply the first number divided by 2. If the number you picked was odd, then the next number is three times the first number, plus one. Each new number is fed back into the function in order to get the next in the sequence.

For example, take the number 21. The hailstones for 21 are as follows:

21, 64, 32, 16, 8, 4, 2, 1, 4, 2, 1 …

The hailstones for 72 are as follows:

72, 36, 18, 9, 28, 14, 7, 22, 11, 34, 17, 52, 26, 13, 40, 20, 10, 5, 16, 8, 4, 2, 1, 4, 2, 1 …

Your first assignment involves a program that will generate some hailstones. Your program will take, as input, a positive integer and then generate the hailstone series for that number. Also, your program will report how many hailstones it took to get the 4,2,1 ending sequence. For example, for the number 21 (see above), the number of hailstones needed to get the 4,2,1 sequence is 5. For 72, it took 20 hailstones.

FUNCTIONS
if f(i) is even: f(i+1) = f(i)/2

if f(i) is odd: f(i+1) = 3f(i)+1

2. ### quickoneNew Member

Joined:
Sep 15, 2004
Messages:
4,179
0
btw this is due for me on monday

Joined:
Sep 15, 2004
Messages:
4,179
0
anyone?

4. ### quickoneNew Member

Joined:
Sep 15, 2004
Messages:
4,179
0
no?

28 looks and not response

Last edited: Mar 27, 2005
5. ### quickoneNew Member

Joined:
Sep 15, 2004
Messages:
4,179
0
Great fucking programming forum this is....not one fucking response.

Joined:
Nov 13, 2001
Messages:
11,865
0
Location:

7. ### JerichoActive Member

Joined:
Oct 21, 2002
Messages:
34,140
0
2) you haven't posted any code or the problem you have

8. ### Penguin ManProtect Your Digital Liberties

Joined:
Apr 27, 2002
Messages:
21,696
0
Location:
Edmonton, AB
This is an extremely easy assignment. No one is going to do it for you. If you try it and have problems, post the problems and someone will help you. Until you try it, no one's going to give a fuck about what you posted.

9. ### quickoneNew Member

Joined:
Sep 15, 2004
Messages:
4,179
0
sry for that previous post I was pissed off at the lab i was trying to do...I do have a problem...yes I did do it and need some help with a little bit that I have left..if anyone is willing to help me...I will post it in a few min

10. ### quickoneNew Member

Joined:
Sep 15, 2004
Messages:
4,179
0
ok...heres the pics of my progress....what I cannot do is circled. Thanks in advance for any help given. rememeber...i'm a huge programming noob.

11. ### quickoneNew Member

Joined:
Sep 15, 2004
Messages:
4,179
0
neone? I listed pics of the code and interface and said what I needed help with

12. ### CyberBulletsI reach to the sky, and call out your name. If I c

Joined:
Nov 13, 2001
Messages:
11,865
0
Location:
that still doesnt mean 100% help since those of us who can help (like me) are neck deep in our own term assignments.

13. ### quickoneNew Member

Joined:
Sep 15, 2004
Messages:
4,179
0
I'm sorry....for whoever has the time to help...would be appreciated. I understand alot of people are busy with their own.

14. ### MarkGuest

Try this:
Inside an endless loop, if hte limit check box is checked exit loop if array occurrence count is greater than limit amount. Then Increase the size of a dynamic array by 1. Using an if statement check for even numbers and one for odd numbers. Inside the if statement, put the answer in the last occurrence of the array. After the if statements check the last three array occurrences for 4,2,1 and exit the loop if present.

Last edited by a moderator: Apr 1, 2005
15. ### CyberBulletsI reach to the sky, and call out your name. If I c

Joined:
Nov 13, 2001
Messages:
11,865
0
Location:
recursion would be better

16. ### MarkGuest

I was thinking that but figured it might be a little complicated for this.

Joined:
Nov 13, 2001
Messages:
11,865