Necklace Problem In Visual Basic

free web hosting
Free Web Hosting > Computers & Tech > Programming > Programming General > BASIC / Visual Basic (.NET)

Necklace Problem In Visual Basic

redskins
I was wondering if anyone could write code for this program. Its the usual Necklace Problem I'll give you the problem.

A Necklace is a collection of numbers that begins with two single digit integers, the next number is obtained by adding the first two digits together and saving only the ones digit. This process is repeated until the 'necklace' closes by returning to the original two numbers.

I think it is a Do While Loop but i am not sure.
Thankyou

Reply

turbopowerdmaxsteel
You are the second person to have reached here for this problem. You can find the VB .NET and C# codes for this problem at http://maxotek.net/blog/?p=51

Its fairly easy to do. I'll jot down the algorithm for the Function that returns the output as a string.

Function Name: Necklace
Inputs: OrigFirstNum (integer) and OrigSecNum (integer)
Return: String

Step 1: Set FirstNum = OrigFirstNum and SecondNum = OrigSecNum
Step 2: Concatenate FirstNum and SecondNum and store the result in Output
Step 3: Repeat Steps 4 - 7 until FirstNum = OrigFirstNum and SecondNum = OrigSecondNum
Step 4: Set Result = FirstNum + SecondNum
Step 5: Set FirstNum = SecondNum
Step 6: Find the last digit of Result and store it in SecondNum
Step 7: Concatenate SecondNum to Output
Step 8: Return Output

To find the last digit of a number use the following algorithm:-

Function Name: GetLastDigit
Input: Num (integer)
Return: Integer

Step 1: Divide Num by 10 and return the remainder

 

 

 


Reply

faulty.lee
QUOTE(redskins @ Dec 7 2007, 04:07 AM) *
I was wondering if anyone could write code for this program. Its the usual Necklace Problem I'll give you the problem.

A Necklace is a collection of numbers that begins with two single digit integers, the next number is obtained by adding the first two digits together and saving only the ones digit. This process is repeated until the 'necklace' closes by returning to the original two numbers.

I think it is a Do While Loop but i am not sure.
Thankyou

You'll need a do loop, as shown in the link posted by turbopowerdmaxsteel. A While loop will need a variable, such as a boolean to be checked every loop. You'll have to exit the loop by changing the variable to false. As for Do loop, you just need to call Exit Do when the condition match what you want.

Reply

tansqrx
Sounds like a homework problem to me. Not that I have never been guilty of doing “research” on the Internet, but I have always found the best way to retain knowledge is to work the problem out on your own. If you develop the mythology for problem solving then you will be able to apply that to many other areas of your life.

Steps off soapbox.

Reply


Got an Opinion! Express your Views! (no registration):-
Add your Reply/ Opinion/ Views/ Comments/ Suggestion/ Questions/ Queries etc.
Posts with decent grammar & English will be accepted and please refrain from profanities.
For asking a Question, We recommend you to sign-up (for free) so that you can track the topic easily.

Nature of your Post*: Opinion/ Reply/ Comments
Question/Query
Feedback to us.
       
Name   Email
Title/Question*

(Maximum characters: 10,000)
You have characters left.
Confirm Code:

Similar Topics

Keywords : necklace, problem, visual, basic

  1. Problem With Div's In Ie6 And Lower
    (2)
  2. An Absolute Basic Guide To Algorithms For Dummies
    (0)
    I really want to learn about algorithms but i dont know how it works at all. Can anyone suggest a
    site, or more preferably a book that can introduce me to algorithms?....
  3. Basic Css
    (6)
    can someone help me learn CSS or give me a good link to learn it....
  4. Visual Studio 2008
    express edition (7)
    Microsoft visual studio 2008 express edition is out! (a long time ago) It contains ± 80% of
    functions of the full version. Link: microsoft express ....
  5. Problem With Acdsee
    is default application (4)
    A girlfriend has a problem with ACDSee (for Pentax). For some reason it has been set as the default
    application for opening folders, so everytime a folder is clicked, ACDSee opens. If already tried to
    fix the file association (changing the default action, adding a new action that opens explorer, but
    it won't work /huh.gif" style="vertical-align:middle" emoid=":huh:" border="0" alt="huh.gif"
    /> ). I've also tried to untick the "browse with acdsee" option in ACDSee, but it doesn't
    remember this option. How can I fix this ?....
  6. Problem With Move_uploaded_file()
    Permission denied? (5)
    CODE Warning: move_uploaded_file(images/profile/Mordent.jpg)
    [function.move-uploaded-file]: failed to open stream: Permission denied in
    /home/mordent/public_html/withvalour/edit_image.php on line 42 Warning:
    move_uploaded_file() [function.move-uploaded-file]: Unable to move
    '/tmp/phpOWVz7o' to 'images/profile/Mordent.jpg' in
    /home/mordent/public_html/withvalour/edit_image.php on line 42 Any ideas? The code seems fine,
    as it works a treat when I run it locally (on WAMPServer), but as soon as I tr....
  7. Administrator Account Problem In Microsoft Xp [solved]
    I have lost "my documents" (20)
    I have problem with administrator account ... I created new administrator account with this way:
    start /control panel /account users/new account and than I created a new one ; after this I turned
    off computer . I wanted to have two skypes turned on and my friend suggested me to do so... when I
    turned it on the second day , I coudn't enter with the first administrator ,and I entered with
    the administrator that I had created . I have lost my document folder.. please help me . how can I
    enter or can I enter with that first administrator account?? Can my documents be ....
  8. A Gaiaonline Problem
    A problem i want to stop (9)
    I have a problem getting on Gaiaonline. When I go it always says "SLOW DOWN Slow down,
    hotshot! You've been loading pages too fast, and our system doesn't like it. Take a
    break for a few minutes so we can catch up! This is not a ban. Come back in a littlw while,
    ok?" and I want it to stop! So can anyone please help me out here?....
  9. Trojan / Virus Problem ,please Help
    might be (hoon) (18)
    I have been infected with atrojan but i can detect it. and i have detected Hoon trojan and deleted
    it ,but the symptoms of the trojan is still on my pcs network " all driver have an autoplay (right
    click by mouse) and it gives my this message by d-click on any driver ************** SYS.EXE
    QUOTE windows cannot find 'sys.exe',make sure you typed the name correctly and then try
    again.to search for a file ,clicl the start botton then clicl search the virus was detected and
    deleted from all drivers: C:\sys.exe D:\sys.exe E:\sys.exe F:\sys....
  10. Fedora Core 6 Install Problem
    (6)
    I have tried three times to get Fedora Core 6 to install but I keep getting the same error message:
    “there was an error running your transaction, for the following reason(s): file conflicts”. I am
    using all of the default settings except changing the time zone and basically installing all
    packages. The error always happens near the end of the fifth disk. I have run sha hash checking on
    all media and everything checks out. Has anyone had this problem or a possible solution?....
  11. Internet Explorer 7 Problem
    Works fine in Firefox! (Shocker) (8)
    Hey, I'm helping my mom with one of her web projects for class and I've noticed a pretty
    big problem (no thanks to IE7) that cost her a few points. It won't load an image of an email
    icon, however, Firefox will load and display it properly. Here's the line for the image: CODE
    <img src="nationalparks/images/email.gif" width="99" height="100"
    border="0" alt="Email" /> Also, IE7 complains about some ActiveX content,
    but this is just a basic page and NO JavaScript, NO Java applets, NO ActiveX of any ki....
  12. Asterisknow Pbx (voip Telephony)
    A basic run down & some questions (1)
    I was wondering if anyone here ever used (or uses) Asterisk? If you don't know what Asterisk is,
    it is a VoIP server (Voice over IP). Basically, it's like Vonage's servers in your home
    (beats the $24.99 month phone bill from Vonage, plus your local phone bill, plus internet
    bill). Anyways, nothing beats a POTS right? Well, features such as Voicemail, call forwarding, voice
    options (menus), etc can come with a price tag from your phone company. You already have copper
    phone lines coming into your house so why should you pay extra for these services when y....
  13. Win Rar Password Problem
    (7)
    i have some trouble with some winrar files password the files is for an ISO and iam trying to remove
    the password because some files has a different password i have tried to change the password but no
    luck ...i used set default password and no luck too if any1 have any idea please post it thanks in
    advance -joe....
  14. C++: Basic Classes
    classes, objects, access labels, members, inline functions (5)
    This tutorial assumes that you have a basic knowledge of C++. You know how to use built-in types,
    like ints, doubles, chars, etc. You should know some types that are part of the STL, like vector,
    etc. Those types that come in the STL are just C++; you can create your own types just like
    those! Non built-in types are referred to as classes . To create a class, you just use the
    keyword class , the name of the class, and curly brackets. CODE //A class named MyClass class
    MyClass { }; In fact, that is all we need to create variables, pointers, or references ....
  15. Problem With Drag And Drop (or So It Seems).
    (11)
    I'm running on Windows XP with Service Pack 1. The last few days, all of a sudden, the drag and
    drop functionality of explorer (or anything on the operating system that uses system calls in order
    to perform it) screws up completely. I attempt to drag it, and it just flickers a bit to the
    direciton I'm moving it and then fails. It doesn't seem to be the mouse as I can still drag
    a rectangle selection to select multiple files etc, just no drag and drop. However, it isn't
    always like that, it works generally (as far as I know) and stop working out of now....
  16. Frustrating Problem With XP On Laptop
    (19)
    I have my Dualcore AMD Acer laptop, 5102Wlmi, with a 120GB hd, 2 GB ram, etc. I had a friend buy it
    in the states and bring it over just 2 months ago. All of a sudden, the other day when i went to
    turn it on, it would bring up the xp boot screen, and then just hang there. I tried a different hard
    drive. no luck. I tired installing XP, but after booting from cd and loading all the drivers, right
    after the FAT and NTFS drivers, it says "Setup is loading Windows" and then it hangs there. I've
    left it overnight and in the morning it's still in the same place. I can&#....
  17. Spam Problem On My Forums
    (25)
    I’m starting to have a real problem in my forums. Apparently “midget anal porn” is the hottest new
    thing. I didn’t think midgets were into that kind of thing but apparently I’m wrong (apologies to
    any midgets out there). I knew that spam may be a problem on my board but I didn’t think that I
    would be a target just yet. I only have 16 registered users (including the spam bots). How in the
    world did they find me? Just like junk mail I figure this problem is only going to get worst since
    I am now apparently on the list. Does anyone have a solution to this problem? I....
  18. Blue Screen - irql_not_less_or_equal
    computer OS Windows problem booting (29)
    Hi , My computer AMD64 256mb RAM / 80GB HDD / Windows XP Professional recently started showing a
    blue screen while starting .. QUOTE A problem has been detected and windows has been shut down
    to prevent further damage to your computer . IRQL_NOT_LESS_OR_EQUAL (blah blah blah ... )
    Technical Information: *** STOP: 0x0000000A (oxFB07D354, ox000000FF, ox00000001, ox804E2E41)
    Initially, if I restarted it would not come the next time. It used to come only randomly. But
    later it started coming more often, and now it did not start for quite a few times con....
  19. Problem With The ReadOnly Property
    (3)
    I have a problem setting the readonly property of a textbox which depends on a yes and no radio
    buttons selection, I'm sure that my code is correct but i dont know why nothing happens. This is
    code: CODE <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML> <HEAD> <TITLE> New Document </TITLE> <script
    LANGUAGE="JavaScript"> <!-- Begin function changeRadio(sVal) {     if
    (sVal=='n')     {         a.textval.readonly=true;         a.texval.value="&#....
  20. Need To Hack An Admin Account On Xp... No Problem!
    It's so easy to hack an account you'll be amazed (61)
    Well recently one of my good girl that is a friend got a laptop from her dad. Her dad does websites
    so the laptop was new and worked fine, but needed to be defraged. The one problem, her nor her dad
    knew the admin password. I told her to post her question on Trap 17 and it got answered with in
    minutes. All you have to do is these few steps: 1. Reboot 2. Before the windows logo comes up press
    F11 (Just start clicking it over and over again until the windows logo comes up.) 3. Just sit and
    let it do it's thing and when the login screen comes up click on the Admin icon....
  21. Photoshop Cropping Problem
    (6)
    All right. For most of my Photoshop work, I use Photoshop 6.0. Yes, I know it's old, but it
    gets the job done, not to mention I just don't have the money of Photoshop CS or Photoshop CS2
    right now. But I'm getting off topic. Anyways, a few months ago, when I went to crop a
    picture, it wouldn't crop all the way. It would crop to a certain point and then just stop and
    refused to go any further with the cropping box. It seems to only form squares and sometimes
    horizontal rectangles, but only to a certain extent. However, when I opened Adobe Photosho....
  22. XP Problem: Clicking On Folder Opens Search
    (4)
    I have no idea why, but for some reason whenever I click on a folder now it opens it as a search
    instead of just showing me the contents. Whenever I right click it, search is at the top of the tab
    in bold instead of open. Is there any way I can fix this? I have no idea what I did wrong. Sorry,
    I fixxed it.....
  23. Einstein Quiz
    Can you solve this problem? (29)
    Hi everybody; I want to ask the quiz written by Einstein last century.It is called Einstein's
    Riddle.Einstein said that 98% of the people in the world cannot solve his riddle. Are you among the
    other 2%?(Hint:It is really easy:) Hints: 1: There are 5 houses in 5 different colors 2: In each
    house lives a person with a different nationality. 3: These 5 owners drink a certain beverage, smoke
    a certain brand of cigar and keep a certain pet. 4: No owners have the same pet, smoke the same
    brand of cigar or drink the same drink. Further Details: a: The Brit lives in a re....
  24. Problem: I Need Urgent Help. Can't Boot.
    (9)
    Hi all. Thanks for reading this, and helping me... /unsure.gif' border='0'
    style='vertical-align:middle' alt='unsure.gif' /> I have a big problem - I must fix one computer
    for one of my important clients, but, everything seems to be fine, until you turn it on (really
    /rolleyes.gif' border='0' style='vertical-align:middle' alt='rolleyes.gif' /> ) ehm, anyway, when
    computer is turned ON, it boots and when it comes to login screen just blocks, and freezes, and
    there's nothing to do there. Sometimes I can manage to click on user to login, but then freezes
    again. .....
  25. Visual Basic 6 + Crystal Reports 9
    how to distribute (6)
    I have made a software with Visual Basic 6 and Crystal Reprots 9. Now I have to distribute it on the
    client side but the problem is coming in distributing the Crystal Reports. I have tried Setup
    Factory but it is not working. Then I have used Visual Studio Installer from Microsoft and
    downloaded Crystal Report Merge Modules from Business Objects website. It is working properly but
    now the setup file size is very big because it carries a lot of files with it. Is there any other
    installer software which can automatically select the required files to be distribute with the ....
  26. Mozilla Firefox And Runescape
    Problem I had with FFox and RScape. (10)
    When I tried to play Runescape in Mozilla's Free browser (Firefox), I couldn't. However,
    when I tried to play the game in Microsoft Internet Explorer, I could. It may be possible to play
    Runescape in Firefox by altering Firefox's settings, or it could just have been me or chance or
    something that caused me to have a problem.....
  27. Visual Basic Help
    need help useing visual basic (5)
    i was just wondering, when you are useing the program Visual Basic is there any way to add some
    animation to a form, and if so what is a good(cheep) animation program i could get?....
  28. Error 406 - Problem In My Phpbb Forum
    Actually a problem with Apache (8)
    When I post the message in my forum contant the word "system" it can't work and said the HTTP
    error 406. I add three Mod : attach mod 2.3.11 , cash mod 2.2.2 , pay money mod 1.0.7 phpBB
    verison 2.0.12 my forum http://siuwing.astahost.com/testmod and then I also setup a model forum
    by cPanel , the error of posting also occur -> http://www.siuwing.astahost.com/testmod2/ the
    model forum havent adding any mod what is the problem ...? /sad.gif' border='0'
    style='vertical-align:middle' alt='sad.gif' /> ....
  29. Basic Tutorial: PHP GD
    basic tuts (15)
    With php gd is the image function library of php. The functions include in this library enable php
    users to creating image up to manipulating photos. PHP gd can create with file extension of jpg,
    gif, swf, tiff and jpeg2000. Installation see http://www.php.net/manual/en/ref.image.php .
    Astahost hosting service has enable gd library, so won’t need any extra works except in coding.
    Lets get started, creating images from php set the canvas: CODE   $img =
    imagecreate(250, 80) imagecreate this function create and set a blank canvas with the
    wide of....
  30. Basic Tips and Tricks in HTML
    (15)
    Here is some quick links for basic html coding... A quick and easy way to create your first web
    page! -> The easiest HTML guide for beginners You'll learn how to create tables from real
    examples. -> How to create TABLE? You will learn how to create frames from a real example.
    You'll see how to create a borderless frame, how to specify the target frame, etc. -> How to
    build FRAMES? Follow a few easy steps to add sound to your web pages. -> How to add sound to a
    web page? This page tells you how to automatically load a visitor to another web p....

    1. Looking for necklace, problem, visual, basic

Searching Video's for necklace, problem, visual, basic
advertisement




Necklace Problem In Visual Basic



 

 

 

 

ADD REPLY / Got an Opinion! a humble request :-) RAPID SEARCH! Free Hosting [X]
Express your Opinions, Thoughts or Contribute more info. to help others.
Ask your Doubts & Queries to get answers, So that "Together We can help others!"
Register FREE for AD-FREE forum, Create your own topics, Ask Questions, track topics, setup subscriptions & notifications and Get a Free Website w/ Email and FTP.
500MB Space *No Ads*, CPanel, FTP, PHP, MySQL, EMails - 100% FREE