Computer Science, asked by Anonymous, 1 year ago

write a program in java to generate composite number 1 to 100

Answers

Answered by manasvini
5
Please mark as brainliest answer

Class composite
{
Void main(int n)
{
Int m=n;int c=0
While(m>0)
{
N=n%10;
If(n%1==0)
C++;
If(c==1)
System.out.println("number of composite numbers=" +m) ;
}
}
}
Hope this helped you
Please mark as brainliest answer


manasvini: yes or no
manasvini: then mark as brainliest answer
Answered by greeshmakachirayil
0

Answer:

A composite number is a non-prime positive integer. In other words, it has a divisor that is not one or itself.

Every integer greater than one is a composite number or a prime number.

One is a unit; it is neither prime nor composite.

How can I determine whether a given number is a composite number or not?

Examples:

n = 21 as an input

Yeah is the answer.

The figure is a composite figure!

n = 11 as an input

No output

/ A Java application that uses an optimal way to determine whether a number is Composite or not.

java.io.* is imported;

Composite class static boolean isComposite(int n) / Corner situations if (n = 1)

System.out.println("False");

System.out.println("False"); if (n = 3)

If (n% 2 == 0 || n% 3 == 0) returns true, we can skip the middle five digits in the next loop.

because (int I = 5; I * I = n; I = I + 6)

Return true if (n% I == 0 || n% I + 2) == 0);

return a false value;

/ Driver Program to test the aforementioned function public static void main (String args[])

System.out.println(isComposite(11)? "true": "false")

System.out.println(isComposite(15) ?

"true" vs. "false");

Learn more about composite numbers here:

https://brainly.in/question/8509522

Learn more about java here:

https://brainly.in/question/13895848

#SPJ2

Similar questions