Trouble understanding programing question.

Hey guys,
Got a program im supposed to write its bonus and I have already done the original program. Problem is Ive read the instructions and they are kinda confusing to me. If I could just understand what they are saying then it will make this much easier. So if anyone can shed some light on what im missing id be thankful.
Heres the program instructions.
Question 2: Design and implement a recursive method that implements the factorial method n!. The factorial method n! is defined by
n!= n*(n-1)*(n-2)*�*1
Place the method in a class that has a main that tests the method.
Does this just mean I need to make a method that finds the factors of a variable (e.g the factors of 10)? Which would be 2 and 5 right? Or would this mean make a recursive method that finds the factors of 10*n. like 1 * 10 = 10, 2 * 10 = 20, 3 * 10 = 30 etc etc.... And Im guessing that that algorightm cant be used in a program. In other words the *....*1 and n! are not correct syntax and that algorithm is just a abstract example to give me some direciton im not actually supposed to try and replicate it exactly as it is right? Usually I dont have problems with instructions but this one just confused the hell out of me. Any help would be great thank you. I would have asked the teacher but I thought I understood it and now I dont see the profeesor until the day its due and also she has a foreign accent so its hard for me to understand.
Message was edited by:
venture

No. You have to do the factorial.
3! = 3*2*1 = 6
4! = 4*3*2*1 = 24
etc
You should see a pattern ie 4! = 4 * 3!. In the
question you were given the equation for calculating
it. If you can't do it Google is your friend becuase
it has been done millions of times before.
Slow! Well it is hard to type with these fins.
Message was edited by:
flounderThat makes sense thank you.

Similar Messages

  • Trouble understanding treemap question

    Okay,
    here is the question:
    Create 10,000 unique random key values in the range 10,000 to 100,000. Hold them in array key. Use Random class's nextInt(n) method to add a random offset to the last randomly value generated. Start with value 1.
    rn = rn + aRandom.nextInt(7) + 1;
    Store Data Objects in the TreeMap and HashMap. Data Objects have the following 4 fields:

    (my post was cut off)
    Create 10,000 unique random key values in the range 10,000 to 100,000. Hold them in array key. Use Random class's nextInt(n) method to add a random offset to the last randomly value generated. Start with value 1.
    rn = rn aRandom.nextInt(7) 1;
    Store Data Objects in the TreeMap and HashMap. Data Objects have the following 4 fields:
    int id; // key;
    string name; // select from 5 names with key[i] % 5
    int age; // 20 + ley % 30
    string gender; // select from "male" or "female" with key[i] % 2the random key values, key, are integers. How do you select from 5 names, that are strings, with key[i] modulus 5?

  • Trouble Understanding Logic of Primes Program

    I am reading a book called Beginning Java 7, by Ivor Horton. In his book he has a primes calculation program. The code is below. I am having trouble understanding the logic of the program. I've stared at it for the past several hours with no luck. What I can't understand is how both i and j are both initialized to 2 but the if statement:
    if(i%j == 0) {
              continue OuterLoop;                                         
            }then passes a 2 to the println() function. I am totally lost on this problem. The program below outputs all of the prime numbers from 2 to 50 without any errors. Please help!
    Thank you.
    public class Primes2 {
      public static void main(String[] args) {
        int nValues = 50;                                                  // The maximum value to be checked
        // Check all values from 2 to nValues
        OuterLoop:
        for(int i = 2 ; i <= nValues ; ++i) {
          // Try dividing by all integers from 2 to i-1
          for(int j = 2 ;  j < i ; ++j) {
            if(i%j == 0) {                                                 // This is true if j divides exactly
              continue OuterLoop;                                          // so exit the loop
          // We only get here if we have a prime
          System.out.println(i);                                           // so output the value
    }Edited by: EJP on 27/03/2013 19:54: fixed all the bizarre formatting, spelling, and removed the even more bizarre comment marketers around the text. Please use standard English and its existing conventions here.

    Hi. I did notice that. What I don't understand is how 2 is outputted as a prime number when the Net Beans debugger shows that i's value is 3 in the if statement. Where does the value 2 come from? Thanks.
    Edited by: 996440 on Mar 27, 2013 3:07 PM

  • Have Trouble understanding the runnable interface

    Hi
    I am new to java programming. I have trouble understanding threading concepts.When I run the below code,Thread3 runs first. I need a small clarification here- I created two thread objects
    Thread thread1=new Thread(new RunnableThread(),"thread1");
    Thread thread2=new Thread(new RunnableThread(),"thread2");
    As soon as I create these objects -Will the constructor with the string argument in the "RunnableThread" class gets invoked. If so why doesn't System.out.println(runner.getName()); get invoked for the above objects. what is the sequence of execution for the below program.
    /*************CODE****************************/
    class RunnableThread implements Runnable
         Thread runner;
         public RunnableThread()
         public RunnableThread(String threadName)
              runner=new Thread(this,threadName);          //Create a new Thread.
              System.out.println(runner.getName());
              runner.start();          //Start Thread
         public void run()
              //Display info about this particular Thread
              System.out.println(Thread.currentThread());
    public class RunnableExample
         public static void main(String argv[])
              Thread thread1=new Thread(new RunnableThread(),"thread1");
              Thread thread2=new Thread(new RunnableThread(),"thread2");
              RunnableThread thread3=new RunnableThread("thread3");
              //start the threads
              thread1.start();
              thread2.start();
              try
                   //delay for one second
                   Thread.currentThread().sleep(1000);
              catch (InterruptedException e)
              //Display info about the main thread
              System.out.println(Thread.currentThread());
    }

    srinivasaditya wrote:
    Hi
    I am new to java programming. I have trouble understanding threading concepts.I'd consider it to be an advanced area.
    When I run the below code,Thread3 runs first. I need a small clarification here- I created two thread objects
    Thread thread1=new Thread(new RunnableThread(),"thread1");
    Thread thread2=new Thread(new RunnableThread(),"thread2");No, this is wrong. You don't need your RunnableThread. Runnable and Thread are enough. Your wrapper offers nothing of value.
    >
    As soon as I create these objects -Will the constructor with the string argument in the "RunnableThread" class gets invoked. If so why doesn't System.out.println(runner.getName()); get invoked for the above objects. what is the sequence of execution for the below program.did you run it and see? Whatever happens, that's the truth.
    %

  • HT4623 I upgraded my iphone4S yesterday and Siri response with "having trouble understanding".  Is there an upgrade for Siri?

    I upgraded my iPhone4S to iOs6 and now Siri does not understand me.  Siri responses "having trouble understanding you, try again".  Is there an updgrade for Siri?  I have been searching all afternoon for a glimmer of a solution.  Any suggestions?

    Sure...
    See this Apple article for a Hard reset of a Factory reset.
    http://support.apple.com/kb/HT3728

  • Having trouble understanding Abstract class. Help!!!!!!

    Having trouble understanding Abstract class. when is Abstract class used and for what.

    Having trouble understanding Abstract class. when is
    Abstract class used and for what.An abstract class is used to force the developer to provide a subclass, to implement the abstract methods, while still keeping the methods that were provided.
    � {�                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

  • Trouble understanding KMP algorithm

    If anyone is familiar with the KMP skip search algorithm and cares to shed some light on the subject. I am having trouble understanding how the table is derived, as many examples i come across seem to be using different variations. The table used to control the search.
    Thanks a million in advance, Mel

    JosAH wrote:
    The failure function can be a bit of a burden to fully understand but realize that it gives you the next index of the string to search for if the current match for a prefix of the pattern failed. thats kind of what i wanted to hear lol, thanks both of you
    and i took ur advice, i did the whole example on pen and paper. i would be lieing if i said i fully understand it, but i do have a better understanding now.
    Mel

  • Trouble understanding static objects

    Hello,
    I have trouble understanding static objects.
    1)
    class TestA
    public static HashMap h = new HashMap();
    So if I add to TestA.h from within a Servlet, this is not a good idea, right?
    But if I just read from it, that is ok, right?
    2)
    class TestB
    public static SimpleDateFormat df = new SimpleDateFormat();
    What about TestB.df from within a Servlet? Is this ok?
    example: TestB.df.format(new Date(1980, 1, 20));

    There is exactly one instance of a static member for every instance of a class. It is okay to use static members in a servlet if they are final, or will not change. If they may change, it is a bad idea. Every call to a servlet launches a new thread. When there are multiple calls, there are multiple threads. If each of these threads are trying to make changes to the static memeber, or use the static memeber while changes are being made, the servelt could give incorrect results.
    I hope that helped..
    Thanks
    Cardwell

  • I have a programming question

    Hi
    I have a programming question here. I spent a lot of time doing it, but I still can't get it. Here is the question :
    Write a method called countTo that takes one integer as a parameter and prints a
    comma-separated list of the numbers from 1 to the value of the parameter, or an
    appropriate error message if the parameter is less than one. In either case (if a list
    of numbers is printed, or an error message is printed), after printing, the cursor
    should be advanced to the next line.
    For example, if the parameter has a value of 1, the method should just print the
    the value 1 to the screen followed by a new-line character. If parameter has a value
    of 5, the method should print the following (exactly as shown, make sure there is
    no comma after the last value, and that all values are on one line with no spaces
    between them):
    1,2,3,4,5
    This method should only print to the screen, and should not return a value.

    I have a programming question here. I spent a lot of
    time doing it, but I still can't get it. Please post what you have done so far.

  • ??Having trouble updating program. Received ERROR message #U44M1P7

    ??Received Error Message after trouble upgrading program. Message...U44M1P7...What do I do to update?

    Many update errors are caused by missing or modified files that Photoshop requires, typically by a disk cleanup utility (such as CleanMyMac or MacKeeper). Make sure that you have the latest updates for your clean-up utilities or discontinue use.
    Explanations of error codes:
    U = Updater.
    44 = Install Update Error
    M1 = Automatic
    P = Patcher
    7 = Installation Failed
    Please visit this link
    http://helpx.adobe.com/creative-suite/kb/error-u44m1p7-installing-updates-ccm.html

  • Trouble opening programs since upgrading to yosemite

    I am having trouble opening programs since upgrading to Yosemite.

    CS 6 or Photoshop 6. CS6 is version 13, Photoshop 6 is super ancient history.
    Either way CS6 should work in Yosemite but not officially supported by Adobe any longer.
    Are you trying to navigate to a location that is not there like a disconnected drive?
    Photoshop tries to remember the last location you opened from
    close photoshop
    open Macintosh HD:Applications:Adobe
    find the Photoshop folder or photoshop.app inside the folder, wherever you installed it
    hold down ctrl+opt+shift+cmd and click on the photoshop icon as you are holding these down
    when the prompt comes up to reset preferences click okay
    you can't do this from the dock icon or an alias btw.
    if that does not work
    create a new admin account,
    boot to that account
    run photoshop,
    if it works there is a problem with your old account and possibly corruption.

  • Trouble gathering program windows after disconnecting display

    I use a 23" Cinema display with my 15" Macbook. I have program windows on both screens. Then I unplug, close the lid (putting the computer to sleep), and go home. When I get home and open it up, often I have trouble gathering program windows onto my laptop. They're open, but i can't see the windows, only the program menu, as if the screen acts like the program windows are on another monitor. I know this because when I use expose, the windows come rushing back into view, but if i try and click that program window, it goes back to where it used to be, off screen. How do i 'consolidate' the windows to my laptop without having to restart?
    Thanks,
    Chris.

    I have the same issue.  It looks as though some applications are still running at non-doubled scale after disconnecting.  Some applications (like Firefox 19+, iTerm, etc.) will display tiny drop-down menus (ex: trying to bookmark after disconnecting) as well as a byproduct.
    I've found that changing the Display resolution to a scaled resolution, and then back to the resolution you want will "refresh" each of the applicaitons.  Bit of a bummer that this workaround is required after disconnecting.

  • Major trouble understanding structure

    Hello,
    This is my first time creating a Photoshop Plugin, and I am having a lot of trouble understanding how to do it. I am using Microsoft MFC to create it. Does anybody know of good references or sample code to look at? I simply don't get how to create this!!!
    I am trying to do a filter plugin that will let the user select a particular color, and turn all other colour in the image to black and white.
    Thanks.

    There is one MFC sample in the SDK. It doesn't sound like you are having trouble with MFC per say but more about getting pixels in and out of Photohsop. Where exactly are you having troubles? Maybe the Dissolve sample will help you out but it uses OS (Win32) API's and not MFC.

  • Please answer a programming question for an admin

    I'm not a programmer (although my interest is growing), so I can't answer this question in a discussion regarding how Win32API w/OLE and COM is SO much better than programming for Unix/OS X applications.
    The original discussion was in regards to OS X's superior Unix based security, he devolved to this. Having only begun my venture into programming, his questions are a little above my head at this point. I'm also interested (as an amature programmer), how this would be accomplished in OS X/Unix.
    Thanks in advance.
    Here's his position:
    *(1st entry)*
    I have unsed Windows and many flavors of Unix and I have written programs in Assembler, Fortran, Pascal, Cobol, RPG, Smalltak, Basic, PowerBuilder, Delphi, C, C++, C#, Java, and Perl, and I have been programming for over 20 years, so I do have extensive knowledge about programming.
    So I have one question for you:
    If you had to build a business application that has to allow users to, spell and grammer check, and perform financial calculations, and render the HTML, how would you compare the effort to do this in Windows versus that in Linux, AIX, Solaris or any other Unix operating system?
    I can make this business application have these features in ONE DAY on Windows, because COM and OLE lets me, use Word to spell and grammer check, Excel to do the financial calculations, and IE to render the HTML!
    I make my living building complex customized business software, and Windows allow me to build these applications by myself in weeks, when it would take me and a team of programmers months to do these same things in Unix because of the lack of an the Win32 API, COM, and OLE, or I would have to BUY third party libraries that did these things, and deal with the licensing, versioning, and vendor problems that go with them, and none of those third party librabries would be close to Word, Excel, and IE in CAPABILITY!
    HONESTLY tell me and others reading this thread how you would go about create the customized business application I described above by yourself in a Unix instead of Windows, and tell us how many MONTHS or YEARS it would take you, or how you would have to BUY some other third party libraries to do what Word, Excel, and IE!
    Anyone who thinks a Unix has more CAPABILITIES than Windows, has never used Win32API/COM/OLE/.Net, and does not build customized complex business software for a living, because we people that do are the reason that you find some much customized business desktop software for Windows, and so little for any Unix.
    I have nothing against Unix, and it is great for simple business tasked server software, but for complex business tasked desktop software Windows with Win32API/COM/OLE/.Net wins hands down!
    *(2nd Entry)*
    A System administrators view of an operating system and an application developers view are entirely different, and the Win32API/COM/OLE/.NET simply make my job so much easier, and you simply don't understand because you do not have to deal with the "dirty' details of making what a user wants, which is why your definition of "integration" and mines are totally different!
    With the spell check you talked about, how will you keep in in synch with the dictionary in Word where the user is constantly adding and removing words?
    No, you would have the user to have to maintain two different spell check dictionaries, and you would totally ignore the grammer check requirement!
    Cutting and pasting data between applications is simple integration, and not the complex type that I am talking about.
    Can you make your application display and use the MacGourmet menus appear in its own window, and to access and use the MacGourmet functionality (ie. search for a recipe) in its own window?
    Give me one example of a Unix application that can display the menus of another application, yet alone control its features!
    Of course you can't, because you need COM and OLE!
    I am quite familiar with different flavors of Unix, but those operating systems do not have the rich API and program integration features namely COM and OLE that Windows has, because it violates the Unix idea of security by process isolation!
    Yes that idea of process isolation keeps the operating system safe from malicious code in applications and from one application taking the others down, but you lose the power of programs working together, and you simply cannot build the type of customized business applications that I build by myself, without reinventing the wheel over and over and without having a large team with lots of programmers.
    For example, my customers and millions of others spend all day working in Word and Excel, and the Windows idea that I can transparently integrate my complex business applications right in Word and Excel menu, and into their templates and macros, is why third party developers like me prefer Windows over Unix, regardless of how much better security in Unix is.
    Do not get me wrong, Java improves business application development on Unix, but unfortuantely it is not feasable to rewrite ever legacy application in Java, and Java does not integrate well with other programming languages.
    I used to code business application for both IBM MVS and Sun Solaris, and I never want to go back to those "bad" old days again, once I took the time to learn how to PROPERLY code using Win32API/COM/OLE/.NET!

    At risk of feeding the troll I'll wander in here:
    NOTE: Since this is an Apple programming boards and I have limited experience programming on traditional Unix systems (and most of that in college) I will confine my answers to the area I know.
    If you had to build a business application that has to allow users to, spell and grammer check, and perform financial calculations, and render the HTML, how would you compare the effort to do this in Windows versus that in Linux, AIX, Solaris or any other Unix operating system?
    I can make this business application have these features in ONE DAY on Windows, because COM and OLE lets me, use Word to spell and grammer check, Excel to do the financial calculations, and IE to render the HTML!
    Note that this scenario assumes the user has Microsoft office installed. The person argues that they don't have to purchase libraries to program but what they are effectively doing is simply transferring that cost to user. I don't have to purchase libraries but everyone of my users needs to. Good for you, very good for Microsoft but bad for your customer - IMHO. OK, I know "But all Windows business users have Office installed already." When it comes free with the system then I'll retract my objection.
    Under OS X and Cocoa many of these functions are intrinsic to the system layer and do not require any applications to be installed. Using Cocoa you can write a simple Word processor that has rulers, full font manipulation (including kerning, spacing and leading), Document Save and Load, Printing, Export to PDF as well as spell-checking in under 10 lines of actual code. Adding a custom file type and icon for full system integration will add another 5 minutes to your programing.
    In case you think I'm blowing smoke here is a tutorial from 2002 (yes, this has been possible for over 5 years) outlining the 8 line Word Processor build in Cocoa. http://www.stone.com/TheCocoa_Files/What_s_sofunny.html
    And yes, Cocoa also includes Webkit so I can add full HTML rendering by dragging in a WebKit window to my user interface. For an experienced Cocoa programmer this certainly sounds like less than a day of programming - in fact it sounds like a good tutorial for a middle-experienced training day or 2 day class in Cocoa.
    I won't include the link to the 1 line web browser you can build in Cocoa using Webkit because it's shorter than the description. Feel free to search for it if you want to.
    HONESTLY tell me and others reading this thread how you would go about create the customized business application I described above by yourself in a Unix instead of Windows, and tell us how many MONTHS or YEARS it would take you, or how you would have to BUY some other third party libraries to do what Word, Excel, and IE!
    BUT this is all done from the stock system that is on every OS X computer not simply those with Office installed. Obviously you'd need to add some features that were more complicated than this - because any halfway decent programmer could turn this stuff out - and polish takes a while but to meet the requirements of the challenge it would take 2 days tops.
    Is every *nix programming environment like this? I don't know I can only answer for the system that I have experience with and is the concern of this board. If you really have questions regarding *nix programming then I suggest you find an appropriate board and troll^H^H^H^H^H ask there.
    If you're ever serious about programming on the Mac feel free to stop by and actually take a look at it. I think you'll be surprised.
    =Tod

  • OOP Programming Question

    Hi,
    Im new to oop in as3.0, just finished my first oop application but there is one thing that i don't understand.
    If i have movieclips on the stage and i want for ex. the display class to control there position and size then
    i need to send it from the document class to the display class using a public method on the display class.
    but after developing my first application i got to a point that all of my methods on the display class were public
    and i used a lot of repatitive code.... ive been told that i need to avoid public methods and try and keep most of the methods in
    the different classes private but the only way to do it is to find a way to pass the movie clip instance to the actual class and control it
    and this way most of the methods in the class will be private and the code on the document class will be a lot more cleaner, but i dont really
    know how to pass a display object to a different class and use it without passing it to a public method through the document class.

    I'm relatively new to OOP programming, so please
    excuse this newbish question :).
    I've been assigned to take over for a co-worker that
    has left for vacation. A class that he wrote is
    partially implemented, so I'm supposed to finish it
    up.
    One class in particular, his constructor is empty.That's fine, if that's what makes sense. I'd have one constructor that set all the private data members. Other constructors would call it using sensible defaults where needed.
    If the ctor is empty and data members are null, that's very bad. An object should be 100 percent ready to go when you create it.
    And to set the instance variables, the user class is
    setting them directly, not through accessor methods.So the data members are public? Oh, my. Where's the encapsulation?
    This seems like a bad idea, and defeats the whole
    purpose of encapsulation. Indeed. Sounds like you know more than your co-worker.
    I wanted to re-do some of the code, but are there any
    good reasons as to why he might be doing this?If it's a DTO C-struct with no other purpose than ferrying data it might be acceptable. I would say it's not acceptable, but that's my opinion.
    Saving some overhead maybe?No, the "overhead" is probably not measurable. I wouldn't optimize such a thing without data that told me it was the bottleneck, and I'd make sure that this "fix" did address the problem before I cast it in stone.
    %

Maybe you are looking for

  • Mapping of complex structure in XI

    Hi friends, I have a RFC to SOAP scenario in XI. As a response message they have given a structure with single field in it. But when it is coming over, it has a complex structure, I need to break it to different fields in my internal table. The respo

  • KDL26M4000 HDMI no signal

    For six months plus, each time I turn on my Sony TV, no picture.  Message on screen:  HDMI No signal. When I reconnect the HDMI cable, the picture is very good.  Same problem when switching to HDMI2 with Sony remote, setting, to designate port.  Two

  • How to run a query several times?

    Hi all, Anyone has a clue for the following situation: We have made a query (on the web) with several characteristics and key-figures. One of the characteristics has unique values that occurs only once (something like numbers for documents in R/3). T

  • Im having trouble downloading the uprgades

    the automatic window pops up to upgrade, but when i click upgrade a blank Internet explorer screen pops up and nothing ever happens. ive tied being patient w/ it but nothing happens! Can u tell whats going on????

  • Exception during cross-component navigation

    Hi all, My requirement is to navigate from the task to the Case. After doing the necessary things for event handling, I have created a outbound plug in the component BT125H_TASK in the view 'TaskDetails'. I have added this outbound plug in the main w