SlideShare a Scribd company logo
1 of 3
Download to read offline
PrimeRange.java
import java.util.Scanner;
public class PrimeRange {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan = new Scanner(System.in);
System.out.println("Enter low range:");
int low = scan.nextInt();
System.out.println("Enter high range:");
int high = scan.nextInt();
for(int i=low; i<=high; i++){
if(isPrime(i))
System.out.print(i+" ");
}
}
public static boolean isPrime(int n){
for (int f = 2; f < n / 2; f++) {
if (n % f == 0) {
return false;
}
}
return true;
}
}
Output:
Enter low range:
10
Enter high range:
30
11 13 17 19 23 29
Solution
PrimeRange.java
import java.util.Scanner;
public class PrimeRange {
/**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner scan = new Scanner(System.in);
System.out.println("Enter low range:");
int low = scan.nextInt();
System.out.println("Enter high range:");
int high = scan.nextInt();
for(int i=low; i<=high; i++){
if(isPrime(i))
System.out.print(i+" ");
}
}
public static boolean isPrime(int n){
for (int f = 2; f < n / 2; f++) {
if (n % f == 0) {
return false;
}
}
return true;
}
}
Output:
Enter low range:
10
Enter high range:
30
11 13 17 19 23 29

More Related Content

Similar to PrimeRange.java import java.util.Scanner;public class PrimeRan.pdf

import java.util.Scanner; public class Palin { public static v.pdf
import java.util.Scanner; public class Palin { public static v.pdfimport java.util.Scanner; public class Palin { public static v.pdf
import java.util.Scanner; public class Palin { public static v.pdfLAMJM
 
SumNumbers.java import java.util.Scanner;public class SumNumbe.pdf
SumNumbers.java import java.util.Scanner;public class SumNumbe.pdfSumNumbers.java import java.util.Scanner;public class SumNumbe.pdf
SumNumbers.java import java.util.Scanner;public class SumNumbe.pdfankkitextailes
 
The sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdfThe sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdfrajat630669
 
The sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdfThe sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdfrajat630669
 
import java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdfimport java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdfoptokunal1
 
Anjalisoorej imca133 assignment
Anjalisoorej imca133 assignmentAnjalisoorej imca133 assignment
Anjalisoorej imca133 assignmentAnjaliSoorej
 
Lab101.pptx
Lab101.pptxLab101.pptx
Lab101.pptxKimVeeL
 
Algoritmos sujei
Algoritmos sujeiAlgoritmos sujei
Algoritmos sujeigersonjack
 
import java.uti-WPS Office.docx
import java.uti-WPS Office.docximport java.uti-WPS Office.docx
import java.uti-WPS Office.docxKatecate1
 
การหาปริมาตรของปร ซึม
การหาปริมาตรของปร ซึมการหาปริมาตรของปร ซึม
การหาปริมาตรของปร ซึมPairy Little
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfmayorothenguyenhob69
 
import java.util.Scanner;public class ArrayOperation {    inp.pdf
import java.util.Scanner;public class ArrayOperation {     inp.pdfimport java.util.Scanner;public class ArrayOperation {     inp.pdf
import java.util.Scanner;public class ArrayOperation {    inp.pdfangelsfashion1
 
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian KomputerKOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian KomputerAiman Hud
 

Similar to PrimeRange.java import java.util.Scanner;public class PrimeRan.pdf (19)

import java.util.Scanner; public class Palin { public static v.pdf
import java.util.Scanner; public class Palin { public static v.pdfimport java.util.Scanner; public class Palin { public static v.pdf
import java.util.Scanner; public class Palin { public static v.pdf
 
SumNumbers.java import java.util.Scanner;public class SumNumbe.pdf
SumNumbers.java import java.util.Scanner;public class SumNumbe.pdfSumNumbers.java import java.util.Scanner;public class SumNumbe.pdf
SumNumbers.java import java.util.Scanner;public class SumNumbe.pdf
 
The sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdfThe sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdf
 
The sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdfThe sample program for above series in JAVA will be like belowimpo.pdf
The sample program for above series in JAVA will be like belowimpo.pdf
 
import java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdfimport java.util.;public class Program{public static void.pdf
import java.util.;public class Program{public static void.pdf
 
Anjalisoorej imca133 assignment
Anjalisoorej imca133 assignmentAnjalisoorej imca133 assignment
Anjalisoorej imca133 assignment
 
Lab101.pptx
Lab101.pptxLab101.pptx
Lab101.pptx
 
Algoritmos sujei
Algoritmos sujeiAlgoritmos sujei
Algoritmos sujei
 
import java.uti-WPS Office.docx
import java.uti-WPS Office.docximport java.uti-WPS Office.docx
import java.uti-WPS Office.docx
 
การหาปริมาตรของปร ซึม
การหาปริมาตรของปร ซึมการหาปริมาตรของปร ซึม
การหาปริมาตรของปร ซึม
 
Review Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdfReview Questions for Exam 10182016 1. public class .pdf
Review Questions for Exam 10182016 1. public class .pdf
 
import java.util.Scanner;public class ArrayOperation {    inp.pdf
import java.util.Scanner;public class ArrayOperation {     inp.pdfimport java.util.Scanner;public class ArrayOperation {     inp.pdf
import java.util.Scanner;public class ArrayOperation {    inp.pdf
 
Oot practical
Oot practicalOot practical
Oot practical
 
Programs of java
Programs of javaPrograms of java
Programs of java
 
Java programs
Java programsJava programs
Java programs
 
Java programs
Java programsJava programs
Java programs
 
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian KomputerKOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
KOLEJ KOMUNITI - Sijil Aplikasi Perisian Komputer
 
Estructura secuencial -garcia
Estructura secuencial -garciaEstructura secuencial -garcia
Estructura secuencial -garcia
 
Java oops features
Java oops featuresJava oops features
Java oops features
 

More from Ankitchhabra28

frequency tableSolution frequency table.pdf
 frequency tableSolution frequency table.pdf frequency tableSolution frequency table.pdf
frequency tableSolution frequency table.pdfAnkitchhabra28
 
ublic class Elevator { private static final String DOWN = down.pdf
  ublic class Elevator {     private static final String DOWN = down.pdf  ublic class Elevator {     private static final String DOWN = down.pdf
ublic class Elevator { private static final String DOWN = down.pdfAnkitchhabra28
 
[Al+] [OH-]^3 = Ksp0.2 [OH-]^3 = 210^-32[OH-] = 4.64210^-1.pdf
[Al+]  [OH-]^3 = Ksp0.2  [OH-]^3 = 210^-32[OH-] = 4.64210^-1.pdf[Al+]  [OH-]^3 = Ksp0.2  [OH-]^3 = 210^-32[OH-] = 4.64210^-1.pdf
[Al+] [OH-]^3 = Ksp0.2 [OH-]^3 = 210^-32[OH-] = 4.64210^-1.pdfAnkitchhabra28
 
As a CFO environment of internal control needs to put in place t.pdf
    As a CFO environment of internal control needs to put in   place t.pdf    As a CFO environment of internal control needs to put in   place t.pdf
As a CFO environment of internal control needs to put in place t.pdfAnkitchhabra28
 
What are the financial markets and what purposes do they serveA f.pdf
What are the financial markets and what purposes do they serveA f.pdfWhat are the financial markets and what purposes do they serveA f.pdf
What are the financial markets and what purposes do they serveA f.pdfAnkitchhabra28
 
VI) Instruction set Architecture-      Instruction set is a colle.pdf
VI) Instruction set Architecture-      Instruction set is a colle.pdfVI) Instruction set Architecture-      Instruction set is a colle.pdf
VI) Instruction set Architecture-      Instruction set is a colle.pdfAnkitchhabra28
 
The OSI(Open System Interconnection) contains 7 layers.1.Physica.pdf
The OSI(Open System Interconnection) contains 7 layers.1.Physica.pdfThe OSI(Open System Interconnection) contains 7 layers.1.Physica.pdf
The OSI(Open System Interconnection) contains 7 layers.1.Physica.pdfAnkitchhabra28
 
the following statements are true Ubiquinone is a small, hydrophob.pdf
the following statements are true Ubiquinone is a small, hydrophob.pdfthe following statements are true Ubiquinone is a small, hydrophob.pdf
the following statements are true Ubiquinone is a small, hydrophob.pdfAnkitchhabra28
 
The evolution of one species is driven by the evolution of the other.pdf
The evolution of one species is driven by the evolution of the other.pdfThe evolution of one species is driven by the evolution of the other.pdf
The evolution of one species is driven by the evolution of the other.pdfAnkitchhabra28
 
Student choosed wrong subject. Question was not showning.Solutio.pdf
Student choosed wrong subject. Question was not showning.Solutio.pdfStudent choosed wrong subject. Question was not showning.Solutio.pdf
Student choosed wrong subject. Question was not showning.Solutio.pdfAnkitchhabra28
 
S(sulfur) atom Glucose molecule and compound Oxygen atom DN.pdf
S(sulfur) atom Glucose molecule and compound Oxygen atom DN.pdfS(sulfur) atom Glucose molecule and compound Oxygen atom DN.pdf
S(sulfur) atom Glucose molecule and compound Oxygen atom DN.pdfAnkitchhabra28
 
Question not visible..please post the imageSolutionQuestion no.pdf
Question not visible..please post the imageSolutionQuestion no.pdfQuestion not visible..please post the imageSolutionQuestion no.pdf
Question not visible..please post the imageSolutionQuestion no.pdfAnkitchhabra28
 
Program 1 public class QueueUsingArray { private static final i.pdf
Program 1 public class QueueUsingArray { private static final i.pdfProgram 1 public class QueueUsingArray { private static final i.pdf
Program 1 public class QueueUsingArray { private static final i.pdfAnkitchhabra28
 
opps no format is there...Solutionopps no format is there....pdf
opps no format is there...Solutionopps no format is there....pdfopps no format is there...Solutionopps no format is there....pdf
opps no format is there...Solutionopps no format is there....pdfAnkitchhabra28
 
Note             Given Code modified as required and required met.pdf
Note             Given Code modified as required and required met.pdfNote             Given Code modified as required and required met.pdf
Note             Given Code modified as required and required met.pdfAnkitchhabra28
 
No, weight is not the measure of quantity of matter.Quantity of ma.pdf
No, weight is not the measure of quantity of matter.Quantity of ma.pdfNo, weight is not the measure of quantity of matter.Quantity of ma.pdf
No, weight is not the measure of quantity of matter.Quantity of ma.pdfAnkitchhabra28
 
Two. The pyruvate with carbons 4-6 will go throu.pdf
                     Two.  The pyruvate with carbons 4-6 will go throu.pdf                     Two.  The pyruvate with carbons 4-6 will go throu.pdf
Two. The pyruvate with carbons 4-6 will go throu.pdfAnkitchhabra28
 
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdfListing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdfAnkitchhabra28
 
is rightSolutionis right.pdf
is rightSolutionis right.pdfis rightSolutionis right.pdf
is rightSolutionis right.pdfAnkitchhabra28
 

More from Ankitchhabra28 (20)

frequency tableSolution frequency table.pdf
 frequency tableSolution frequency table.pdf frequency tableSolution frequency table.pdf
frequency tableSolution frequency table.pdf
 
ublic class Elevator { private static final String DOWN = down.pdf
  ublic class Elevator {     private static final String DOWN = down.pdf  ublic class Elevator {     private static final String DOWN = down.pdf
ublic class Elevator { private static final String DOWN = down.pdf
 
[Al+] [OH-]^3 = Ksp0.2 [OH-]^3 = 210^-32[OH-] = 4.64210^-1.pdf
[Al+]  [OH-]^3 = Ksp0.2  [OH-]^3 = 210^-32[OH-] = 4.64210^-1.pdf[Al+]  [OH-]^3 = Ksp0.2  [OH-]^3 = 210^-32[OH-] = 4.64210^-1.pdf
[Al+] [OH-]^3 = Ksp0.2 [OH-]^3 = 210^-32[OH-] = 4.64210^-1.pdf
 
As a CFO environment of internal control needs to put in place t.pdf
    As a CFO environment of internal control needs to put in   place t.pdf    As a CFO environment of internal control needs to put in   place t.pdf
As a CFO environment of internal control needs to put in place t.pdf
 
What are the financial markets and what purposes do they serveA f.pdf
What are the financial markets and what purposes do they serveA f.pdfWhat are the financial markets and what purposes do they serveA f.pdf
What are the financial markets and what purposes do they serveA f.pdf
 
VI) Instruction set Architecture-      Instruction set is a colle.pdf
VI) Instruction set Architecture-      Instruction set is a colle.pdfVI) Instruction set Architecture-      Instruction set is a colle.pdf
VI) Instruction set Architecture-      Instruction set is a colle.pdf
 
waitSolutionwait.pdf
waitSolutionwait.pdfwaitSolutionwait.pdf
waitSolutionwait.pdf
 
The OSI(Open System Interconnection) contains 7 layers.1.Physica.pdf
The OSI(Open System Interconnection) contains 7 layers.1.Physica.pdfThe OSI(Open System Interconnection) contains 7 layers.1.Physica.pdf
The OSI(Open System Interconnection) contains 7 layers.1.Physica.pdf
 
the following statements are true Ubiquinone is a small, hydrophob.pdf
the following statements are true Ubiquinone is a small, hydrophob.pdfthe following statements are true Ubiquinone is a small, hydrophob.pdf
the following statements are true Ubiquinone is a small, hydrophob.pdf
 
The evolution of one species is driven by the evolution of the other.pdf
The evolution of one species is driven by the evolution of the other.pdfThe evolution of one species is driven by the evolution of the other.pdf
The evolution of one species is driven by the evolution of the other.pdf
 
Student choosed wrong subject. Question was not showning.Solutio.pdf
Student choosed wrong subject. Question was not showning.Solutio.pdfStudent choosed wrong subject. Question was not showning.Solutio.pdf
Student choosed wrong subject. Question was not showning.Solutio.pdf
 
S(sulfur) atom Glucose molecule and compound Oxygen atom DN.pdf
S(sulfur) atom Glucose molecule and compound Oxygen atom DN.pdfS(sulfur) atom Glucose molecule and compound Oxygen atom DN.pdf
S(sulfur) atom Glucose molecule and compound Oxygen atom DN.pdf
 
Question not visible..please post the imageSolutionQuestion no.pdf
Question not visible..please post the imageSolutionQuestion no.pdfQuestion not visible..please post the imageSolutionQuestion no.pdf
Question not visible..please post the imageSolutionQuestion no.pdf
 
Program 1 public class QueueUsingArray { private static final i.pdf
Program 1 public class QueueUsingArray { private static final i.pdfProgram 1 public class QueueUsingArray { private static final i.pdf
Program 1 public class QueueUsingArray { private static final i.pdf
 
opps no format is there...Solutionopps no format is there....pdf
opps no format is there...Solutionopps no format is there....pdfopps no format is there...Solutionopps no format is there....pdf
opps no format is there...Solutionopps no format is there....pdf
 
Note             Given Code modified as required and required met.pdf
Note             Given Code modified as required and required met.pdfNote             Given Code modified as required and required met.pdf
Note             Given Code modified as required and required met.pdf
 
No, weight is not the measure of quantity of matter.Quantity of ma.pdf
No, weight is not the measure of quantity of matter.Quantity of ma.pdfNo, weight is not the measure of quantity of matter.Quantity of ma.pdf
No, weight is not the measure of quantity of matter.Quantity of ma.pdf
 
Two. The pyruvate with carbons 4-6 will go throu.pdf
                     Two.  The pyruvate with carbons 4-6 will go throu.pdf                     Two.  The pyruvate with carbons 4-6 will go throu.pdf
Two. The pyruvate with carbons 4-6 will go throu.pdf
 
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdfListing.javaimport java.util.Scanner;public class Listing {   .pdf
Listing.javaimport java.util.Scanner;public class Listing {   .pdf
 
is rightSolutionis right.pdf
is rightSolutionis right.pdfis rightSolutionis right.pdf
is rightSolutionis right.pdf
 

Recently uploaded

Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfJayanti Pande
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingTeacherCyreneCayanan
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Sapana Sha
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfchloefrazer622
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDThiyagu K
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdfQucHHunhnh
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactPECB
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfagholdier
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 

Recently uploaded (20)

Web & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdfWeb & Social Media Analytics Previous Year Question Paper.pdf
Web & Social Media Analytics Previous Year Question Paper.pdf
 
fourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writingfourth grading exam for kindergarten in writing
fourth grading exam for kindergarten in writing
 
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111Call Girls in Dwarka Mor Delhi Contact Us 9654467111
Call Girls in Dwarka Mor Delhi Contact Us 9654467111
 
Disha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdfDisha NEET Physics Guide for classes 11 and 12.pdf
Disha NEET Physics Guide for classes 11 and 12.pdf
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
Measures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SDMeasures of Dispersion and Variability: Range, QD, AD and SD
Measures of Dispersion and Variability: Range, QD, AD and SD
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Beyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global ImpactBeyond the EU: DORA and NIS 2 Directive's Global Impact
Beyond the EU: DORA and NIS 2 Directive's Global Impact
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 

PrimeRange.java import java.util.Scanner;public class PrimeRan.pdf

  • 1. PrimeRange.java import java.util.Scanner; public class PrimeRange { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner scan = new Scanner(System.in); System.out.println("Enter low range:"); int low = scan.nextInt(); System.out.println("Enter high range:"); int high = scan.nextInt(); for(int i=low; i<=high; i++){ if(isPrime(i)) System.out.print(i+" "); } } public static boolean isPrime(int n){ for (int f = 2; f < n / 2; f++) { if (n % f == 0) { return false; } } return true; } } Output: Enter low range: 10 Enter high range: 30 11 13 17 19 23 29
  • 2. Solution PrimeRange.java import java.util.Scanner; public class PrimeRange { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub Scanner scan = new Scanner(System.in); System.out.println("Enter low range:"); int low = scan.nextInt(); System.out.println("Enter high range:"); int high = scan.nextInt(); for(int i=low; i<=high; i++){ if(isPrime(i)) System.out.print(i+" "); } } public static boolean isPrime(int n){ for (int f = 2; f < n / 2; f++) { if (n % f == 0) { return false; } } return true; } } Output: Enter low range: 10 Enter high range:
  • 3. 30 11 13 17 19 23 29