Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Solution by Samkit
- import java.util.*;
- public class UserMainCode {
- static Scanner sc = new Scanner(System.in);
- public static int minimumMoves(int N){
- int ans = N;
- for(int i=2;i*i<=N;i++) {
- if(N%i==0) {
- ans = i;
- break;
- }
- }
- return 1 + ((N-ans)/2);
- }
- public static void main(String[] args) {
- int N = sc.nextInt();
- System.out.println(minimumMoves(N));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment