DEV Community

Neelakandan R
Neelakandan R

Posted on

1 1 1 1

while loop

1.Look at this series: 53, 53, 40, 40, 27, 27, ... What number should come next?
12
14
27
53
Explanation:
In this series, each number is repeated, then 13 is subtracted to arrive at the next number.

package B14;

public class num00 {
    public static void main(String[] args) {
        int no = 53;
        int count = 0;
        while (count < 10) {
            System.out.println(no);
            System.out.println(no);
            no = no - 13;
            count = count + 2;
        }

    }
}

Enter fullscreen mode Exit fullscreen mode

Output:
53
53
40
40
27
27
14
14
1
1

2.Look at this series: 22, 21, 23, 22, 24, 23, ... What number should come next?
22
24
25
26
Explanation:
In this simple alternating subtraction and addition series; 1 is subtracted, then 2 is added, and so on.

package B14;

public class num11 {
    public static void main(String[] args) {
        int no = 22;
        int count = 0;
        while (count < 2) {
            System.out.println(no);
            no = no - 1;
            System.out.println(no);
            no = no + 2;
            count = count + 1;
        }

    }

}

Enter fullscreen mode Exit fullscreen mode

Output:
22
21
23
22
24
23
25
24
26
25
27
26
.
3.Look at this series: 36, 34, 30, 28, 24, ... What number should come next?
20
22
23
26
Explanation:
This is an alternating number subtraction series. First, 2 is subtracted, then 4, then 2, and so on.

package B14;

public class num22 {
    public static void main(String[] args) {
        int no=36;
        int count = 0;
        while(count<5)
        {
            System.out.println(no);
            no=no-2;
            System.out.println(no);
            no=no-4;
            count=count+2;
        }


    }

}


Enter fullscreen mode Exit fullscreen mode

Output:
36
34
30
28
24
22

4.Look at this series: 21, 9, 21, 11, 21, 13, 21, ... What number should come next?
14
15
21
23
Explanation:
In this alternating repetition series, the random number 21 is interpolated every other number into an otherwise simple addition series that increases by 2, beginning with the number 9.

package B14;

public class num23 {
    public static void main(String[] args) {
        int num1 = 21;
        int num = 9;
        int count = 0;
        while (count < 6) {
            System.out.println(num1);
            System.out.println(num);
            num = num + 2;

            count = count + 1;
        }
    }
}



Enter fullscreen mode Exit fullscreen mode

output:

9
21
11
21
13
21
15
21
17
21
19

5.Look at this series: 58, 52, 46, 40, 34, ... What number should come next?
26
28
30
32
Explanation:
This is a simple subtraction series. Each number is 6 less than the previous number.

package B14;

public class num24 {
    public static void main(String[] args) {
        int num = 58;
        int count = 0;
        while (count < 6) {
            System.out.println(num);
            num = num - 6;
            count++;
        }
    }

}

Enter fullscreen mode Exit fullscreen mode

Output:
58
52
46
40
34
28

6.Look at this series: 3, 4, 7, 8, 11, 12, ... What number should come next?
7
10
14
15
Explanation:
This alternating addition series begins with 3; then 1 is added to give 4; then 3 is added to give 7; then 1 is added, and so on.

package B14;

public class num25 {
    public static void main(String[] args) {
        int num = 3;
        int count = 0;
        while (count < 6) {
            System.out.println(num);
            num = num + 1;
            System.out.println(num);
            num = num + 3;
            count = count + 1;
        }

    }
}
Enter fullscreen mode Exit fullscreen mode

Output:
3
4
7
8
11
12
15
16
19
20
23
24

7.Look at this series: 31, 29, 24, 22, 17, ... What number should come next?
15
14
13
12
Explanation:
This is a simple alternating subtraction series, which subtracts 2, then 5.

package B14;

public class num26 {
    public static void main(String[] args) {
        int num = 31;
        int count = 0;
        while (count < 5) {
            System.out.println(num);
            num = num - 2;
            System.out.println(num);
            num = num - 5;
            count = count + 1;
        }
    }
}

Enter fullscreen mode Exit fullscreen mode

output:
31
29
24
22
17
15
10
8
3
1

8.Look at this series: 1.5, 2.3, 3.1, 3.9, ... What number should come next?
4.2
4.4
4.7
5.1
Explanation:
In this simple addition series, each number increases by 0.8.

package B14;

public class num27 {

    public static void main(String[] args) {
        double num = 1.5;
        int count = 0;
        while (count < 6) {
            System.out.println(num);
            num = num + 0.8;
            count++;
        }

    }

}

Enter fullscreen mode Exit fullscreen mode

**
output:**

1.5
2.3
3.0999999999999996
3.8999999999999995
4.699999999999999
5.499999999999999

**
9.Look at this series: 14, 28, 20, 40, 32, 64, ... What number should come next?

52
56
96
128
Explanation:**
This is an alternating multiplication and subtracting series: First, multiply by 2 and then subtract 8.

package B14;

public class num28 {
    public static void main(String[] args) {
        int num = 14;
        int count = 0;
        while (count < 4) {
            System.out.println(num);
            num = num * 2;
            System.out.println(num);
            num = num - 8;
            count = count + 1;
        }
    }
}

Enter fullscreen mode Exit fullscreen mode

Output:
14
28
20
40
32
64
56
112

10.Look at this series: 5.2, 4.8, 4.4, 4, ... What number should come next?
3
3.3
3.5
3.6
Explanation:
In this simple subtraction series, each number decreases by 0.4.

package B14;

public class num29 {
    public static void main(String[] args) {
        double num = 5.2;
        int count = 0;
        while (count < 6) {
            System.out.println(num);
            num = num - 0.4;
            count++;
        }

    }
}


Enter fullscreen mode Exit fullscreen mode

Output:

5.2
4.8
4.3999999999999995
3.9999999999999996
3.5999999999999996
3.1999999999999997

Top comments (0)

Image of Datadog

The Essential Toolkit for Front-end Developers

Take a user-centric approach to front-end monitoring that evolves alongside increasingly complex frameworks and single-page applications.

Get The Kit

👋 Kindness is contagious

Discover a treasure trove of wisdom within this insightful piece, highly respected in the nurturing DEV Community enviroment. Developers, whether novice or expert, are encouraged to participate and add to our shared knowledge basin.

A simple "thank you" can illuminate someone's day. Express your appreciation in the comments section!

On DEV, sharing ideas smoothens our journey and strengthens our community ties. Learn something useful? Offering a quick thanks to the author is deeply appreciated.

Okay