From ef07bf16874febda94f2a619f8961bb9ce55aec5 Mon Sep 17 00:00:00 2001 From: Suraj649 <69170640+Suraj649@users.noreply.github.com> Date: Mon, 13 Jun 2022 01:15:20 +0530 Subject: [PATCH] Update PrimeNumber.java --- week1/day1/assignments/PrimeNumber.java | 87 +++++-------------------- 1 file changed, 15 insertions(+), 72 deletions(-) diff --git a/week1/day1/assignments/PrimeNumber.java b/week1/day1/assignments/PrimeNumber.java index 28f5a0a..b6dbfdc 100644 --- a/week1/day1/assignments/PrimeNumber.java +++ b/week1/day1/assignments/PrimeNumber.java @@ -3,81 +3,24 @@ public class PrimeNumber { - - - /* - - * Goal: To find whether a number is a Prime number or not - - * - - * input: 13 - - * output: 13 is a Prime Number - - * - - * Shortcuts: - - * 1) Print : type: syso, followed by: ctrl + space + enter - - * 2) To create a 'for' loop: type 'for', followed by ctrl + space + down arrow + enter - - * 3) To create an 'if' condition: type 'if', followed by ctrl + space +down arrow + enter - - * - - * What are my learnings from this code? - - * 1) - - * 2) - - * 3) - - * - - */ - - - public static void main(String[] args) { - - - - // Declare an int Input and assign a value 13 - - - - // Declare a boolean variable flag as false - - - - // Iterate from 2 to half of the input - - - - // Divide the input with each for loop variable and check the remainder - + Prime(7); + } + + public static void Prime(int n ) { + boolean res= true; + for (int i=2;i