Sequences for n = 5:
1 2 6 12 20
1 2 6 24 120
1 4 9 16 25
100 50 200 100 400
2 5 8 11 14
1 3 6 10 15
1 1 2 3 5 8 13
0 2 6 12 20
20 22 18 24 16
0 1 3 7 15
I have to make it so it prints that, each on a new line, exactly like that.
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.
Sequences for n = 5:
1 2 6 12 20
1 2 6 24 120
1 4 9 16 25
100 50 200 100 400
2 5 8 11 14
1 3 6 10 15
1 1 2 3 5 8 13
0 2 6 12 20
20 22 18 24 16
0 1 3 7 15
I have to make it so it prints that, each on a new line, exactly like that.
What do you expect us to do, write the code for you?
How about working out what the sequence for each output is. Some are easier than others. Once you know the sequence, the Java code will follow.
Improving the world one idiot at a time!
Each loop will require 2 or more variables. You might also need to ise an if statement inside some of the loops. None are very difficult.
Improving the world one idiot at a time!
But if I told you how to do it I would have done the work not you. On the other hand if you make an attempt, get stuck and ask a specific question about your code I can provide hints and guide you towards doing the work yourself.
Improving the world one idiot at a time!
a = 1; int b = 1; for (int i = 1; i <= n; i++) //come back to this later { System.out.print(a + " "); }
There's my code. (For the first set of outputs)
Does it compile?
Does it run?
Does it do what you want?
Improving the world one idiot at a time!