Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- class TestClass {
- public static void main(String args[] ) throws Exception {
- Scanner sc = new Scanner(System.in);
- int t = sc.nextInt();
- while(t-- > 0) {
- int n = sc.nextInt();
- int ans = n - 1;
- for(int i = (int)Math.sqrt(n); i >= 1; i--) {
- if(n % i == 0) {
- ans = n / i - i;
- break;
- }
- }
- System.out.println(ans);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement