Help me with this number printing series program. | Sololearn: Learn to code for FREE!
New course! Every coder should learn Generative AI!
Try a free lesson
0

Help me with this number printing series program.

Can somebody please help me with the program to print the series ( 3 6 8 10 13 15 17 20 ) and logic behind it? Thanks in Advance!!

27th Apr 2018, 8:18 PM
Nabeel
Nabeel - avatar
2 Answers
+ 1
Thanks Sajeda!! But the question is about series suppose if we have to print 100 numbers in this sequence. Would you be able to do it manually? maybe not so we have to find a logic to print the series. check this fibonacci series code this might help. // print the series 0 1 1 2 3 5 8 13 21 34 55 package com.Maths; public class Fibonacci { public static void main(String[] args) { int n1 = 0, n2 = 1, n3; System.out.print(n1 + " " + n2); for (int n = 1; n <= 10; n++) { n3 = n2 + n1; System.out.print(" " + n3); n1 = n2; n2 = n3; } } }
27th Apr 2018, 8:47 PM
Nabeel
Nabeel - avatar
0
define an array and initialize it with these numbers. then you can write for loop and print them one by one
27th Apr 2018, 8:35 PM
sajede mirzaei
sajede mirzaei - avatar