Skip to content

Commit 7f27c27

Browse files
committed
feat: Generate and print Geometric Progression (GP) series
🧠 Logic: - Accept input values: first term `a`, common ratio `r`, and number of terms `n`. - Initialize `term` with `a`. - Use a for loop to iterate `n` times: - Print the current `term`. - Multiply `term` by `r` to get the next term in the GP. Signed-off-by: Somesh diwan <[email protected]>
1 parent ec5d2ec commit 7f27c27

File tree

1 file changed

+1
-4
lines changed

1 file changed

+1
-4
lines changed

Section8LoopAB/src/GeomatircSeries.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,12 +13,9 @@ public static void main(String[] args) {
1313

1414
int term=a;
1515

16-
for (int i=0;i<n;i++)
17-
{
16+
for (int i=0;i<n;i++) {
1817
System.out.print(term+",");
19-
2018
term=term*r;
21-
2219
}
2320
}
2421
}

0 commit comments

Comments
 (0)