★★★★★
"The one step solution for my son. Modern Age Coders make learning coding so simple that kids love it. The teachers explain complex concepts clearly with practical exercises and interactive content."
Ria Mukherjee
Parent
ICSE Class 10 · Computer Applications (Java) · Series programs 2027
Series programs in Java for ICSE either print the first n terms of a sequence or add them up. Every one of them is a single loop, and what differs is where the next term comes from: the loop counter, the term before it, the two terms before it, a sign that flips, or a factorial that grows. This page sorts fourteen series into those five loop patterns, gives a print or sum version of each, with the result Java 21 actually printed, and shows how the same work is done in our live mini batch.
Live online · fourteen series, five loop patterns · print and sum versions · Fibonacci and factorial without recursion · first class free
Start here
The ICSE Java course where these series form part of the weekly batch work, the Class 11 and 12 Computer Science course where series return inside ISC programs, and the CBSE Class 10 Maths prep course for a student who wants the sequences and progressions behind them on firmer ground.

The batch / ICSE CA
The full Class 9 and 10 syllabus in small groups; every series starts as a term table and ends as a BlueJ run.
Open the course →
Next step / ISC
After Class 10, ISC brings series back inside longer programs, and recursion joins the toolkit there.
Open the course →
Maths support / Class 10
For the student who finds arithmetic progressions and powers shaky and wants them steady before writing series in code.
Open the course →Ans. The short version
Series programs in Java for ICSE Class 10 print the first n terms of a sequence or find the sum of a series using one loop. They fall into five loop patterns: the term is a formula in the counter (1/i²), it is built from the previous term (1, 11, 111), it is the sum of the two before it (Fibonacci), the sign alternates, or a factorial or running total grows inside the loop. Use double for fractions and long for large terms. Modern Age Coders teaches them live twice a week in a small ICSE batch in India, with private one to one lessons as the other option.
Q1. How do you recognise which loop a series needs?
Write the first four terms in a column, then ask where each term comes from. If you can work out term i from i alone, it is pattern 1. If you need the term before it, it is pattern 2. Two terms before it: pattern 3. A sign that flips: pattern 4. A product or total that keeps growing: pattern 5.
| Pattern | Example series | The line that makes the term | On this page |
|---|---|---|---|
| 1. Term from the counter | 2, 5, 10, 17, ... | term = i * i + 1; | Q2 |
| 2. Term from the previous term | 1, 11, 111, 1111, ... | t = t * 10 + 1; | Q3 |
| 3. Term from the two previous terms | 0, 1, 1, 2, 3, 5, ... | c = a + b; a = b; b = c; | Q4 |
| 4. Alternating sign | 1 - 2 + 3 - 4 + ... | s = s + sign * i; sign = -sign; | Q5 |
| 5. Running factorial or total | 1! + 2! + 3! + ... | f = f * i; s = s + f; | Q5 |
The loop is the same in both. A print version calls System.out.print(term + " ") inside the loop. A sum version declares s = 0 before the loop, adds each term with s = s + term, and prints s once, after the loop. Printing s inside the loop is the most common slip: the answer then shows every partial sum instead of one total.
| Choose | When | Why |
|---|---|---|
int | Whole-number terms that stay small | Exact and simple |
long | Terms that grow fast: 1, 11, 111, powers, factorials | 13! is already past the int limit of about 2.1 billion |
double | Any term with division or Math.pow | 1 / (i * i) in int arithmetic is 0 for every i above 1 |
Q2. How do you write a sum of series program in Java?
If term i can be written straight from i, put that formula inside a for loop from 1 to n. Use a decimal point (1.0) or Math.pow whenever the term divides, so Java works in double.
class FromCounter {
static void printTerms(int n) { // 2, 5, 10, 17, ...
for (int i = 1; i <= n; i++)
System.out.print(i * i + 1 + " ");
System.out.println();
}
static void sumTerms(int n) { // 1 + 1/4 + 1/9 + ... + 1/n^2
double s = 0;
for (int i = 1; i <= n; i++)
s = s + 1.0 / (i * i);
System.out.println("Sum = " + s);
}
static void oddPowers(double x, int n) { // x + x^3 + x^5 + ... n terms
double s = 0;
for (int i = 1; i <= n; i++)
s = s + Math.pow(x, 2 * i - 1);
System.out.println("Sum = " + s);
}
public static void main(String args[]) {
printTerms(6);
sumTerms(4);
oddPowers(2, 4);
}
}
2 5 10 17 26 37 Sum = 1.4236111111111112 Sum = 170.0
In printTerms, i * i + 1 is worked out before the String " " joins it, because * and the first + both act on numbers. oddPowers for x = 2 is 2 + 8 + 32 + 128, which is 170; Math.pow returns double, so Java prints 170.0.
Math.pow, Math.sqrt and the other Math methods a series may need, with their return types, are on Math library methods for ICSE Class 10.
Q3. What if each term depends on the one before it?
Keep the current term in a variable outside the loop and update it once per pass. The update line is the whole idea: multiply by 10 and add a digit, multiply by a ratio, or add a growing gap.
class FromPrevious {
static void ones(int n) { // 1, 11, 111, ...
long t = 0;
for (int i = 1; i <= n; i++) {
t = t * 10 + 1;
System.out.print(t + " ");
}
System.out.println();
}
static void sumTwos(int n) { // 2 + 22 + 222 + ...
long t = 0, s = 0;
for (int i = 1; i <= n; i++) {
t = t * 10 + 2;
s = s + t;
}
System.out.println("Sum = " + s);
}
static void times3(int n) { // 1, 3, 9, 27, ...
long t = 1;
for (int i = 1; i <= n; i++) {
System.out.print(t + " ");
t = t * 3;
}
System.out.println();
}
static void growingGaps(int n) { // 1, 2, 4, 7, 11, ...
int t = 1;
for (int i = 1; i <= n; i++) {
System.out.print(t + " ");
t = t + i;
}
System.out.println();
}
public static void main(String args[]) {
ones(5);
sumTwos(4);
times3(7);
growingGaps(8);
}
}
1 11 111 1111 11111 Sum = 2468 1 3 9 27 81 243 729 1 2 4 7 11 16 22 29
Look at the order of the two lines inside each loop. In ones the term is updated and then printed, so t starts at 0. In times3 it is printed and then updated, so t starts at 1. Both orders work if the starting value matches.
| Pass i | t = t * 10 + 2 | s = s + t |
|---|---|---|
| 1 | 2 | 2 |
| 2 | 22 | 24 |
| 3 | 222 | 246 |
| 4 | 2222 | 2468 |
The growing-gaps series adds 1, then 2, then 3: the gap is the counter itself. Series like this are easy to misread as a formula in i; the term table in Q1 tells you quickly that the differences, not the terms, follow i. The loop habits behind all of this are practised on loop programs in Java for ICSE Class 10.
Q4. How do you print the Fibonacci series in Java for ICSE?
Each Fibonacci term is the sum of the two before it, starting 0 and 1. Keep the last two terms in a and b; each pass prints a, makes c = a + b, then slides the pair one place: a takes b, and b takes c. No recursion is needed, and recursion is not in the ICSE 2027 syllabus.
import java.util.Scanner;
class Fibonacci {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
System.out.print("How many terms? ");
int n = sc.nextInt();
int a = 0, b = 1, sum = 0;
for (int i = 1; i <= n; i++) {
System.out.print(a + " ");
sum = sum + a;
int c = a + b; // next term
a = b; // slide the pair along
b = c;
}
System.out.println();
System.out.println("Sum of the terms = " + sum);
}
}
The order a = b, then b = c matters. Swap those two lines and both a and b take the new value, so the run prints 0 1 2 4 8 16, doubling instead of Fibonacci.
| Variable | Type | Purpose |
|---|---|---|
| n | int | number of terms to print |
| a, b | int | the current term and the one after it |
| c | int | the next term, a + b |
| sum | int | total of the printed terms |
| i | int | loop counter, 1 to n |
How many terms? 10 0 1 1 2 3 5 8 13 21 34 Sum of the terms = 88
When the question gives a largest value instead of a number of terms, the count is unknown, so use while with the limit as the condition.
class FibLimit {
public static void main(String args[]) {
int a = 0, b = 1;
while (a <= 100) {
System.out.print(a + " ");
int c = a + b;
a = b;
b = c;
}
System.out.println();
}
}
0 1 1 2 3 5 8 13 21 34 55 89
The next term, 144, fails a <= 100, so the loop stops after 89. A for loop to a fixed n could not know to stop here.
Checking whether one given number is a Fibonacci number, and other single-number tests, sit with the number families on special number programs in Java for ICSE.
Q5. How do you handle alternating signs and factorial series?
For a sign that flips, keep a variable sign that starts at 1 and is multiplied by -1 every pass, or test whether i is even. For a factorial series, never write a second loop to work out each factorial: multiply the running factorial by i, and it is ready for this term.
class SignSeries {
static void plusMinus(int n) { // 1 - 2 + 3 - 4 + ... n terms
int s = 0, sign = 1;
for (int i = 1; i <= n; i++) {
s = s + sign * i;
sign = -sign;
}
System.out.println("Sum = " + s);
}
static void powerOverIndex(double x, int n) { // x - x^2/2 + x^3/3 - ...
double s = 0;
for (int i = 1; i <= n; i++) {
double term = Math.pow(x, i) / i;
if (i % 2 == 0)
s = s - term;
else
s = s + term;
}
System.out.println("Sum = " + s);
}
public static void main(String args[]) {
plusMinus(7);
plusMinus(10);
powerOverIndex(2, 4);
}
}
Sum = 4 Sum = -5 Sum = -1.3333333333333335
For x = 2 and four terms: 2 - 2 + 8/3 - 4, which is -4/3. The two methods show both ways of flipping the sign; either earns the marks.
class FactSeries {
static void sumOfFactorials(int n) { // 1! + 2! + 3! + ... + n!
long f = 1, s = 0;
for (int i = 1; i <= n; i++) {
f = f * i; // f is now i!
s = s + f;
}
System.out.println("Sum = " + s);
}
static void expSeries(double x, int n) { // 1 + x/1! + x^2/2! + ... n terms after 1
double term = 1, s = 1;
for (int i = 1; i <= n; i++) {
term = term * x / i; // builds x^i / i! from the last term
s = s + term;
}
System.out.println("Sum = " + s);
}
static void runningTotals(int n) { // 1 + (1+2) + (1+2+3) + ...
int p = 0, s = 0;
for (int i = 1; i <= n; i++) {
p = p + i; // p is now 1 + 2 + ... + i
s = s + p;
}
System.out.println("Sum = " + s);
}
public static void main(String args[]) {
sumOfFactorials(5);
expSeries(1, 10);
runningTotals(5);
}
}
Sum = 153 Sum = 2.7182818011463845 Sum = 35
1 + 2 + 6 + 24 + 120 is 153. With x = 1 the exp series adds 1/i! terms and creeps towards the number e, 2.71828. The running total adds 1, 3, 6, 10 and 15.
| i | f = f * i | s = s + f |
|---|---|---|
| 1 | 1 | 1 |
| 2 | 2 | 3 |
| 3 | 6 | 9 |
| 4 | 24 | 33 |
| 5 | 120 | 153 |
Overloading questions often carry a series in one of their versions; that shape is covered on user-defined methods and overloading for ICSE Class 10, or as one option of a switch menu on menu driven programs for ICSE.
Q6. How are series taught in the live class?
The hard part of a series question is not the loop but reading the series correctly. Lessons spend their time there.
At the Tuesday 5:30 PM IST class, students get a series they have not met, written the way the paper writes it, sometimes with an x to read in.
Each student writes i beside the first four terms and names the loop pattern, then writes the one line that makes the term.
The program is written on paper with a variable description table, and the sum of the first three terms is worked by hand as the check value.
At the Wednesday 8:00 PM IST class the programs are run. If BlueJ disagrees with the hand sum, the group traces the loop to find whether the term, the type or the print position was wrong.
Later in the year the same families come back as parts of whole mock papers, sat in two hours and marked question by question.
Every other Section B family has its own page, linked from ICSE Class 10 Java programs for practice, and nested loops that print shapes instead of numbers are on pattern programs for ICSE.
Batch or personalised: you choose
In both formats series are read with a term table, written by hand, checked against a hand sum and then run. Families in India choose between the fixed evening mini batch and a private slot; ICSE students abroad study one to one. Billing is monthly with no admission fee.
Option 1 · Fixed batch timings
₹2,999
per month, two live classes a week
Option 2 · Choose your own timing
₹4,999
per month, one private class a weektwo private classes a week, at a time set with you
Outside India: the ICSE Computer Applications course runs as personalised one to one, two private classes a week at a time set in your own time zone. The mini batch is taught for families in India.
Students who can code a loop but misread what the series is asking often need only a handful of one to one sessions on term tables. Students who want every Section B family covered in a steady rhythm are better placed in the twice-weekly batch. Each format's fee is listed in your local currency.
Studying outside India?
ICSE schools outside India sit the same Computer Applications paper, so the same series turn up in Section B, often inside an overloading question. Families abroad book private lessons, timed for the end of their school day.
| Where you live | Time difference | Usual class window, local time | Format |
|---|---|---|---|
| India (IST) every Indian city | IST | Tue 5:30 PM, Wed 8:00 PM | Mini batch or 1-on-1 |
| United Arab Emirates Dubai, Sharjah | 1 h 30 min behind India | 3:00 PM to 9:00 PM | Personalised 1-on-1 |
| Indonesia and Thailand West Java, Bangkok area | 1 h 30 min ahead of India | 3:30 PM to 9:00 PM | Personalised 1-on-1 |
| Singapore Singapore | 2 h 30 min ahead of India | 3:30 PM to 9:00 PM | Personalised 1-on-1 |
The slot is settled after the free demo and shifts around school tests when needed. Details for overseas families are on ICSE Computer Applications classes in the Gulf and abroad.
What families say
Real reviews from real families. We neither write nor commission them.
★★★★★
"The one step solution for my son. Modern Age Coders make learning coding so simple that kids love it. The teachers explain complex concepts clearly with practical exercises and interactive content."
Ria Mukherjee
Parent
★★★★★
"Modern Age Coders has been a game-changer for me. I struggled to grasp IT concepts and coding before joining, but their classes transformed everything. I can now confidently write complex programs with ease."
Samriddha Mondal
Student
★★★★★
"One of the most wonderful education centres out there. Education is not limited to school syllabus but focuses on skill development."
Vansh Agarwal
Student
★★★★★
"My child Dhairya is really enjoying the Modern Age Coders classes. This is his first online class and he eagerly looks forward to it. I can already see his improvement, and the teachers are very cooperative."
Sonam Oswal
Parent of Dhairya
★★★★★
"Modern Age Coders have wonderful teachers who teach in a clear, easy and practical way. The teacher boosts students' confidence and inspires them to learn without hesitation."
Sonu Goyal
Parent
★★★★★
"I highly recommend this computer coding class! The teachers are incredibly knowledgeable and passionate about coding."
Ritu Kedia
Parent
The rest of the Class 10 series
Every page in the ICSE Class 10 Computer Applications series, grouped by what you need: classes, each chapter, Section B programs, question practice, notes and revision, and the exam itself.
CBSE Class 10 AI (417): The Mon and Wed 9 PM AI batch CBSE AI 417 syllabus explained CBSE AI important questions Sample paper and mock tests
Questions about series programs
Write the first four terms with their positions 1, 2, 3, 4, and find where each term comes from: a formula in the position, the previous term, the two previous terms, a flipping sign or a growing factorial. Then write one for loop from 1 to n that makes the term and either prints it or adds it to a sum.
Declare a sum variable before the loop and set it to 0. Inside the loop, work out the current term and add it with s = s + term. Print s once, after the loop ends. Use double for s whenever any term involves division or Math.pow.
Start with a = 0 and b = 1. In each pass of a loop print a, then set c = a + b, a = b and b = c. For the first n terms use a for loop; for all terms up to a limit use a while loop that runs as long as a has not passed the limit. Recursion is not needed and is not in the ICSE 2027 syllabus.
Keep a running factorial f that starts at 1 and becomes f * i in each pass, so it equals i! for the current term. Add f, or a term built from it, to the sum. Do not write a separate inner loop for each factorial. Use long, because factorials pass the int limit at 13!.
Usually because of integer division. In 1 / (i * i) both sides are int, so the answer is 0 for every i above 1. Write 1.0 / (i * i) or cast to double, and make the sum variable a double.
Keep an int sign that starts at 1, multiply each term by sign, and set sign = -sign at the end of every pass. Or test i % 2: add the term when i is odd and subtract it when i is even. Both are accepted.
Keep a term t that starts at 0, and in each pass set t = t * 10 + 1 and print it. The same idea with + 2 gives 2, 22, 222. Use long, because these terms grow by a factor of ten each time.
Use for when the number of terms n is given, because the counter doubles as the term position. Use while when the series must stop at a value, such as all terms up to 100, because the number of passes is not known in advance.
They matter a lot. Series test loops, data types and careful reading at once. They come as whole Section B programs, and also as one branch of a larger overloading or menu program. Getting the term right is most of the work.
We do. Each week the small ICSE batch meets a new series, reads it with a term table, writes the program by hand, checks a hand sum and runs it in BlueJ on a shared screen. Private one to one lessons are the alternative when batch times clash.
Start
During the demo your child reads an unfamiliar series with the mentor, builds the term table, writes the loop and checks a hand sum against BlueJ. Afterwards you get an honest view of where the gaps are, reading, types or loops, and whether the mini batch or one to one suits better.
Planning the whole year? Start from ICSE Computer Applications important questions or the ICSE Class 10 Java classes.
WhatsApp us · +91 91233 66161 · connect@modernagecoders.com
Every class is live video. The form requests a callback and reserves nothing.
A full live class of about 45 to 60 minutes at a slot you pick, with a written skill report and learning roadmap on WhatsApp afterwards. The fee is adjusted against your first month if you enrol.
Book a priority demo