SHARE
TWEET

Untitled

a guest Jan 27th, 2019 71 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package telerikalpha.workshop.training;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Homework {
  6.     public static void main(String[] args) {
  7.         Scanner userInpit = new Scanner(System.in);
  8.         int numberN = userInpit.nextInt();
  9.         int counter = 0;
  10.  
  11.       /*  for(int i = numberN - 1; i >= 1; i--){
  12.             counter++;
  13.             if(numberN % i == 0){
  14.                 break;
  15.             }
  16.         }*/
  17.  
  18.         if (numberN > 1) {
  19.             for (int j = 2; j < numberN; j++) {
  20.  
  21.                 if (numberN % j == 0) {
  22.                     counter = numberN - (numberN / j);
  23.                     break;
  24.                 }
  25.             }
  26.         }
  27.  
  28.         System.out.println(counter);
  29.     }
  30. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top