Results 1 to 5 of 5

Thread: Recursive Function

  1. #1

    Thread Starter
    Fanatic Member pvbangera's Avatar
    Join Date
    Sep 2001
    Location
    Mumbai, India
    Posts
    961

    Recursive Function

    if someone from C programing knows how to print first 10 prime nos. using recursion, pls let me know.

    also let me know if this is possible in VB

    regards,
    prakash

  2. #2
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    Recursion is definitely possible in VB, so you can write such a program.

    Also I don't have a ready code and am too lazy to write it on the fly, so I can't give you a ready code.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  3. #3
    Addicted Member Mandelbrot's Avatar
    Join Date
    Aug 2001
    Location
    Work, as usual!!
    Posts
    241
    Why not just work out the first 10 numbers and stick 'em in an array?! It just seems like such a waste of processing for 10 primes!

    Excepting 1:
    2,3,5,7,11,13,17,19,23,29

    PS, I found VB a bit slow for this kind of task up to any "reasonable" number (unless you've got a "resonable processor, but C's still the best bet - write it into a DLL).

  4. #4
    Randalf the Red honeybee's Avatar
    Join Date
    Jun 2000
    Location
    off others' brains
    Posts
    4,345

    Well ...

    The use of recursion is tomorrow if you need the first 100 prime numbers, you just need to change a couple of lines, at the most.

    Using your technique it would not be possible to extend the program.

    .
    I am not a complete idiot. Some parts are still missing.
    Check out the rtf-help tutorial
    General VB Faq Thread
    Change is the only constant thing. I have not changed my signature in a long while and now it has started to stink!
    Get more power for your floppy disks. ; View honeybee's Elite Club:
    Use meaningfull thread titles. And add "[Resolved]" in the thread title when you have got a satisfactory response.
    And if that response was mine, please think about giving me a rep. I like to collect them!

  5. #5
    Addicted Member Mandelbrot's Avatar
    Join Date
    Aug 2001
    Location
    Work, as usual!!
    Posts
    241
    Ah, don't get me wrong, Honeybee - recursion is a very useful method of producing repetitive results, but VB isn't the pretiest of languages (bit like Swan Lake in full plate armour). I just believe that VB isn't really the language for such routines - you need to have VB code as compact and quick as possible.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width