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

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

  1. quickone

    quickone New Member

    Joined:
    Sep 15, 2004
    Messages:
    4,179
    Likes Received:
    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:


    [​IMG]

    If f(i) is odd:





    [​IMG]



    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. quickone

    quickone New Member

    Joined:
    Sep 15, 2004
    Messages:
    4,179
    Likes Received:
    0
    btw this is due for me on monday:(
     
  3. quickone

    quickone New Member

    Joined:
    Sep 15, 2004
    Messages:
    4,179
    Likes Received:
    0
    anyone?
     
  4. quickone

    quickone New Member

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

    28 looks and not response
     
    Last edited: Mar 27, 2005
  5. quickone

    quickone New Member

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

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    :rofl:
     
  7. Jericho

    Jericho Active Member

    Joined:
    Oct 21, 2002
    Messages:
    34,140
    Likes Received:
    0
    1) your pictures don't work, upload it somewhere :slap:
    2) you haven't posted any code or the problem you have
     
  8. Penguin Man

    Penguin Man Protect Your Digital Liberties

    Joined:
    Apr 27, 2002
    Messages:
    21,696
    Likes Received:
    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. quickone

    quickone New Member

    Joined:
    Sep 15, 2004
    Messages:
    4,179
    Likes Received:
    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. quickone

    quickone New Member

    Joined:
    Sep 15, 2004
    Messages:
    4,179
    Likes Received:
    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.

    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]
    [​IMG]
     
  11. quickone

    quickone New Member

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

    CyberBullets I reach to the sky, and call out your name. If I c

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

    quickone New Member

    Joined:
    Sep 15, 2004
    Messages:
    4,179
    Likes Received:
    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. Mark

    Mark Guest

    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. CyberBullets

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    recursion would be better
     
  16. Mark

    Mark Guest

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

    CyberBullets I reach to the sky, and call out your name. If I c

    Joined:
    Nov 13, 2001
    Messages:
    11,865
    Likes Received:
    0
    Location:
    BC, Canada/Stockholm, Sweden
    no its a very simple recursive method. :mamoru:
     

Share This Page