# java algorithem

Kavinda Chathuranga
java algorithem
Posted in : Java Beginners

how do i write a algorithm to find all prime numbers less than 100, can you give me the code example?

November 4, 2010 at 1:10 PM

import java.io.*; class Primeseries { public static void main(String args[]) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.print("enter no.:"); int n=Integer.parseInt(br.readLine()); int i=3,j,k=1,count; System.out.println("prime no. are :"); if(n==1) System.out.println(i); else if(n>=2) { System.out.println(k+"\n"+(k+1));

```for(i=3;i<=n;i++)
{count=0;
for(j=1;j<=i;j++)
{
int d=i%j;
if(d==0)
count++;
}
if(count<=2)
System.out.println(i);

}
```

} }}

give n as 100.

November 4, 2010 at 1:17 PM

import java.io.*; class Primeseries { public static void main(String args[]) throws IOException { BufferedReader br=new BufferedReader(new InputStreamReader(System.in)); System.out.print("enter no.:"); int n=Integer.parseInt(br.readLine()); int i=1,j,k=1,count; System.out.println("prime no. are :"); if(n==1) System.out.println(i); else if(n>=2) { System.out.println(k+"\n"+(k+1));

```for(i=3;i<=n;i++)
{count=0;
for(j=1;j<=i;j++)
{
int d=i%j;
if(d==0)
count++;
}
if(count<=2)
System.out.println(i);

}
```

} }}

give n as 100.

java algorithem
java algorithem  how do i write a algorithm to find all prime numbers less than 100, can you give me the code example?   import java.io.*; class Primeseries { public static void main(String args[]) throws IOException
java
java  3.write an algorithem and the java program that declars.... for example 197mintes becomes 3 hours ad 17 minutes save the program as time java. Write an algorithem aprogram that reads an integer between0 and 1000 and adds all
java
java  diff bt core java and java
java
java  what is java
JAVA
JAVA  how the name came for java language as "JAVA
java
java   why iterator in java if we for loop
java
java  explain technologies are used in java now days and structure java
java
java  different between java & core java
Java
Java   Whether Java is pure object oriented Language
java
java  is java open source
java
java  what is java reflection
java
java   in java does not pointers concept but what is nullpointers in java?   nullpointer is a runtime Exception
java
what is the size of array in java ?  what is the size of array in java ? what is the mean of finalize in java
java
java   What is ?static? keyword
java
java  RARP implementation using java socket
java
java  sample code for RARP using java
java
java  Does java allows multiline comments
java
java  give a simple example for inheritance in java
java
java  give a simple example for inheritance in java
java
java  why to set classpath in java
java
java  why to set classpath in java
java
java  why to set classpath in java
java
java  Write a java code to print "ABABBABCABABBA
java
java  write a program in java to acess the email
java
java  send me java interview questions
java
java  what are JAVA applications development tools
Java
Java   Whether Java is Programming Language or it is SOftware
java
java  is java purely object oriented language
java
java  explain object oriented concept in java
java
java   difference between class and interface
Java
Java  how to draw class diagrams in java