Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 3e0fdc9

Browse files
Generate the Series
1 parent 678a996 commit 3e0fdc9

11 files changed

+28
-62
lines changed

‎InterviewPrograms/src/com/java/series/ArithmeticProgression.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
/*
66
* Arithmetic Progression
7-
*
7+
* -----------------------
88
* In mathematics, an arithmetic progression (AP)
99
* or arithmetic sequence is a sequence of
1010
* numbers such that the difference between the

‎InterviewPrograms/src/com/java/series/EvenNumberSeries.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
import java.util.Scanner;
44

55
/*
6-
* Print the EVEN number series
7-
*
6+
* EVEN Number Series
7+
* ------------------
88
* 0 2 4 6 8 10 12 14 ....
99
*
1010
* In the for loop, either use i++, check i is even and print

‎InterviewPrograms/src/com/java/series/GeometricProgression.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
/*
66
* Geometric Progression
7-
*
7+
* ---------------------
88
* In mathematics, a geometric progression, also known
99
* as a geometric sequence, is a sequence of numbers
1010
* where each term after the first is found by multiplying
@@ -32,6 +32,7 @@
3232
* 9 = 256 * 2 = 512
3333
* 10 = 512 * 2 = 1024
3434
*/
35+
3536
public class GeometricProgression {
3637
public static void main(String[] args) {
3738
Scanner scanner = new Scanner(System.in);

‎InterviewPrograms/src/com/java/series/OddNumberSeries.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,15 @@
33
import java.util.Scanner;
44

55
/*
6-
* Print the ODD number series
7-
*
6+
* ODD Number Series
7+
* ------------------
88
* 1 3 5 7 9 11 13 15 17 19 .....
99
*
1010
* In the for loop, either use i++, check i is odd and print
1111
* Else in the for loop use i+=2 then print i value
1212
* i starts with value 1
1313
*/
14+
1415
public class OddNumberSeries {
1516
public static void main(String[] args) {
1617
Scanner scanner = new Scanner(System.in);

‎InterviewPrograms/src/com/java/series/PatternSeries.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
* and append 3 for every iteration
1212
*
1313
*/
14+
1415
public class PatternSeries {
1516
public static void main(String[] args) {
1617
Scanner scanner = new Scanner(System.in);
@@ -45,5 +46,5 @@ public static void main(String[] args) {
4546
Enter the N value for the series : 10
4647
3 33 333 3333 33333 333333 3333333 33333333 333333333 -961633963
4748
Using String approach:
48-
3 33 333 3333 33333 333333 3333333 33333333 333333333 -961633963
49+
3 33 333 3333 33333 333333 3333333 33333333 333333333 3333333333
4950
*/

‎InterviewPrograms/src/com/java/series/PrimeNumberSeries.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,17 +2,18 @@
22

33
/*
44
* Prime Number Series
5-
*
5+
* --------------------
66
* 2, 3, 5, 7, 11, 13, 17, 19, 23, 29 ....
77
*
88
* Prime Number
9-
*
9+
* ------------
1010
* A prime number is a natural number greater than 1
1111
* that is not a product of two smaller natural numbers.
1212
*
1313
* A natural number thats divisible only by itself and 1.
1414
*
1515
*/
16+
1617
public class PrimeNumberSeries {
1718
public static void main(String[] args) {
1819
int n = 100;

‎InterviewPrograms/src/com/java/series/QuadraticSequence.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
/*
44
* Quadratic Sequence
5-
*
5+
* ------------------
66
* A quadratic sequence is a sequence of numbers
77
* in which the second difference between
88
* any two consecutive terms is constant.
@@ -24,6 +24,15 @@
2424
*
2525
* The Series is
2626
* 1, 2, 4, 7, 11, 16, 22
27+
*
28+
* for values i = 1 to n
29+
* 1 = ( (1 * (1-1) ) / 2) + 1 = 1
30+
* 2 = ( (2 * (2-1) ) / 2) + 1 = 2
31+
* 3 = ( (3 * (3-1) ) / 2) + 1 = 4
32+
* 4 = ( (4 * (4-1) ) / 2) + 1 = 7
33+
* 5 = ( (5 * (5-1) ) / 2) + 1 = 11
34+
* 6 = ( (6 * (6-1) ) / 2) + 1 = 16
35+
*
2736
*/
2837
public class QuadraticSequence {
2938
public static void main(String[] args) {

‎InterviewPrograms/src/com/java/series/Series1.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
/*
44
* Print the following Series
55
* 2 9 28 65 126 217 344
6-
*
6+
* -------------------------
77
* for i-th element
88
* (i^3)+1
99
*
@@ -16,6 +16,7 @@
1616
* i = 7 => 7^3+たす1 = 343 +たす 1 = 344
1717
*
1818
*/
19+
1920
public class Series1 {
2021
public static void main(String[] args) {
2122
int n = 10;

‎InterviewPrograms/src/com/java/series/Series5.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
/*
66
* Write Java program to generate the following Series
77
*
8-
* 1 2 3 7 11 16 22 29
8+
* 1 2 4 7 11 16 22 29
99
*
1010
* Solution is
1111
* i-th value = ( (i * (i-1) ) / 2) + 1

‎InterviewPrograms/src/com/java/series/Series7.java

Lines changed: 0 additions & 50 deletions
This file was deleted.

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /