File tree Expand file tree Collapse file tree 5 files changed +83
-0
lines changed
DataStructuresImplementation Expand file tree Collapse file tree 5 files changed +83
-0
lines changed Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <classpath >
3+ <classpathentry kind =" src" path =" src" />
4+ <classpathentry kind =" con" path =" org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.8" />
5+ <classpathentry kind =" output" path =" bin" />
6+ </classpath >
Original file line number Diff line number Diff line change 1+ /bin /
Original file line number Diff line number Diff line change 1+ <?xml version =" 1.0" encoding =" UTF-8" ?>
2+ <projectDescription >
3+ <name >DataStructuresImplementation</name >
4+ <comment ></comment >
5+ <projects >
6+ </projects >
7+ <buildSpec >
8+ <buildCommand >
9+ <name >org.eclipse.jdt.core.javabuilder</name >
10+ <arguments >
11+ </arguments >
12+ </buildCommand >
13+ </buildSpec >
14+ <natures >
15+ <nature >org.eclipse.jdt.core.javanature</nature >
16+ </natures >
17+ </projectDescription >
Original file line number Diff line number Diff line change 1+ eclipse.preferences.version =1
2+ org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode =enabled
3+ org.eclipse.jdt.core.compiler.codegen.targetPlatform =1.8
4+ org.eclipse.jdt.core.compiler.codegen.unusedLocal =preserve
5+ org.eclipse.jdt.core.compiler.compliance =1.8
6+ org.eclipse.jdt.core.compiler.debug.lineNumber =generate
7+ org.eclipse.jdt.core.compiler.debug.localVariable =generate
8+ org.eclipse.jdt.core.compiler.debug.sourceFile =generate
9+ org.eclipse.jdt.core.compiler.problem.assertIdentifier =error
10+ org.eclipse.jdt.core.compiler.problem.enumIdentifier =error
11+ org.eclipse.jdt.core.compiler.source =1.8
Original file line number Diff line number Diff line change 1+ package com .geeksforgeeks ;
2+
3+ import java .io .BufferedReader ;
4+ import java .io .IOException ;
5+ import java .io .InputStreamReader ;
6+
7+ public class PrimeNumberGenerator
8+ {
9+ public static void main (String [] args ) throws IOException
10+ {
11+ int n ;
12+
13+ System .out .println ("Enter the input" );
14+ //methods to take input
15+ InputStreamReader isr = new InputStreamReader (System .in );
16+ BufferedReader br = new BufferedReader (isr );
17+
18+ n = Integer .parseInt (br .readLine ());
19+
20+ //it will help to identify the prime numbers
21+ boolean prime [] = new boolean [n +1 ];
22+
23+ //initialize the boolean matrix
24+ for (int i =2 ; i <=n ; i ++)
25+ {
26+ prime [i ] = true ;
27+ }
28+
29+ for (int i =2 ; i <Math .sqrt (n ); i ++)
30+ {
31+ for (int j =i *i ; j <=n ; j += i )
32+ {
33+ if (j %i == 0 ) //it will check whether a number has a factor or not
34+ {
35+ prime [j ] = false ;
36+ }
37+ }
38+ }
39+
40+ System .out .println ("The prime nos smaller than " + n + " are..." );
41+ for (int i =2 ; i <=n ; i ++)
42+ {
43+ if (prime [i ] == true )
44+ System .out .print (i + " " );
45+ }
46+ }
47+
48+ }
You can’t perform that action at this time.
0 commit comments