Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 12 of 12

Thread: 0-10Factorial table

  1. #1
    Member
    Join Date
    Mar 2013
    Posts
    35
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default 0-10Factorial table

    How can I make a factorial table for the numbers 0-10...I want it printed so 0 1, 1 1, 2, 2, 3 6 etc, but I do not know how.


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: 0-10Factorial table

    If you don't understand my answer, don't ignore it, ask a question.

  3. #3
    Member
    Join Date
    Mar 2013
    Posts
    35
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: 0-10Factorial table

    This is only for the numbers 1-30, but I don't know how to calculate its factorial and match it up with the given integer.
    public static void factorial() {
    int sum, number = 10;
    for (int i = 1; i <= number; i++)
    {
    System.out.print(i + "\t");
    sum = 1;

  4. #4
    Member Chris.Brown.SPE's Avatar
    Join Date
    May 2008
    Location
    Fort Wayne, Indiana
    Posts
    190
    Thanks
    1
    Thanked 31 Times in 31 Posts

    Default Re: 0-10Factorial table

    What are you stuck on? Figuring out the algorithm for factorials or how to put it to code?
    Writing code is your job, helping you fix and understand it is mine.

    <-- Be sure to thank and REP (Star icon) those who have helped you. They appreciate it!

  5. #5
    Member
    Join Date
    Mar 2013
    Posts
    35
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: 0-10Factorial table

    how to put it to code

  6. #6
    Member Chris.Brown.SPE's Avatar
    Join Date
    May 2008
    Location
    Fort Wayne, Indiana
    Posts
    190
    Thanks
    1
    Thanked 31 Times in 31 Posts

    Default Re: 0-10Factorial table

    Are you looking for a recursive solution our something straight forward?
    Writing code is your job, helping you fix and understand it is mine.

    <-- Be sure to thank and REP (Star icon) those who have helped you. They appreciate it!

  7. #7
    Member
    Join Date
    Mar 2013
    Posts
    35
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: 0-10Factorial table

    Quote Originally Posted by Chris.Brown.SPE View Post
    Are you looking for a recursive solution our something straight forward?
    something straightforward, i'm pretty sure the recursive way needs the method to be an integer but that requires return statements.

  8. #8
    Member Chris.Brown.SPE's Avatar
    Join Date
    May 2008
    Location
    Fort Wayne, Indiana
    Posts
    190
    Thanks
    1
    Thanked 31 Times in 31 Posts

    Default Re: 0-10Factorial table

    Ok, so you're trying to write an iterative (non-recursive) factorial program. If you have the iterative factorial algorithm, which part is causing you problems? Or do you not have an iterative factorial algorithm?
    Writing code is your job, helping you fix and understand it is mine.

    <-- Be sure to thank and REP (Star icon) those who have helped you. They appreciate it!

  9. #9
    Member
    Join Date
    Mar 2013
    Posts
    35
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: 0-10Factorial table

    I do not have the right iterative factorial algorithm

  10. #10
    Member Chris.Brown.SPE's Avatar
    Join Date
    May 2008
    Location
    Fort Wayne, Indiana
    Posts
    190
    Thanks
    1
    Thanked 31 Times in 31 Posts

    Default Re: 0-10Factorial table

    A factorial is simply the number multiplied by all numbers previous to it.

    8! = 8*7*6*5*4*3*2*1 or 1*2*3*4*5*6*7*8

    Looks like a simple for loop to me. Google "iterative factorial algorithm" if you're still having issues with the algorithm after seeing this explanation.
    Writing code is your job, helping you fix and understand it is mine.

    <-- Be sure to thank and REP (Star icon) those who have helped you. They appreciate it!

  11. #11
    Member
    Join Date
    Mar 2013
    Posts
    35
    Thanks
    2
    Thanked 0 Times in 0 Posts

    Default Re: 0-10Factorial table

    I'm good, thanks for your help!

  12. #12
    Junior Member
    Join Date
    Feb 2013
    Posts
    1
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Default Re: 0-10Factorial table

    s
    Quote Originally Posted by my21 View Post
    This is only for the numbers 1-30, but I don't know how to calculate its factorial and match it up with the given integer.
    public static void factorial() {
    int sum, number = 10;
    for (int i = 1; i <= number; i++)
    {
    System.out.print(i + "\t");
    sum = 1;


    --- Update ---

    thanks.... it help me lot..

Similar Threads

  1. Addition Table.
    By LoganC in forum What's Wrong With My Code?
    Replies: 7
    Last Post: October 4th, 2012, 12:02 PM
  2. Java Table
    By mija in forum What's Wrong With My Code?
    Replies: 1
    Last Post: September 16th, 2012, 09:35 AM
  3. Dataset to a table
    By despistada14 in forum Web Frameworks
    Replies: 1
    Last Post: May 11th, 2012, 04:18 PM
  4. Object Table
    By aussiemcgr in forum AWT / Java Swing
    Replies: 3
    Last Post: June 2nd, 2011, 01:16 PM
  5. table comparison
    By awecode in forum JDBC & Databases
    Replies: 2
    Last Post: October 12th, 2010, 09:37 AM