Computer Science, asked by arpan3548, 2 months ago

Write Java program to accept a number.if it is positive Odd write 3 successive positive Odd or write 3 predessor numbers​

Answers

Answered by SP85
0

import java.util.*;

class GFG

{

static void checksum(int n)

{

if (n == 0)

{

System.out.println("-1 0 1");

return;

}

int inc;

if (n > 0)

inc = 1;

else

inc = -1;

for (int i = 0; i <= n - 2; i += inc)

{

if (i + i + 1 + i + 2 == n) {

System.out.println(i + " " +

(i + 1) +

" " + (i + 2));

return;

}

}

System.out.println("-1");

}

public static void main(String[] args)

{

int n = 6;

checksum(n);

}

}

Answered by jasvindarsinghkuttan
3

Explanation:

answer is in attachment

mark me brainliest please

Attachments:
Similar questions