log in
About and Contact
© 2020 DOUBTCOOL
Nnjk
Gandhi .......the cause of the untouchables.
Geek is a spy in an enemy town. There are N people in the town and every person has a unique natural number that denotes their identification. The person's identification code is His organisation has however, planted several alties in the town. They can be identified by their identification code as the digits in their codes form the smallest possible permutation Given N, find out how many atties Seok has in the town
Geek is a spy in an enemy town. There are N people in the town and every person has a unique natural number that denotes their identification. The person's identification code is His organisation has however, planted several alties in the town. They can be identified by their identification code as the digits in their codes form the smallest possible permutation Given N, find out how many atties Seok has in the town
Back ⌕ Type keywords of your question MELLAM RAMuploaded on 7th April 2021 05:57 AMother | other | other Geek is a spy in an enemy town. There are people in the town and every person has a unique natural number that denotes the identification. The person's identification code is organisation has however planted several alles in the town They can be identified by the identification code as the digits in the code for the smallest possible permutation Given N. find out how many allies Book has in the town Example 1: Input: N 13 Output: 12 Explanation: Tdentification codes of Geeks allies are 1, 2, 3, 4, 5, 6, 7, , 9, 11, 12 and 13. Person with Identification code 10 cannot be an ally as 10 is not the smallest permutation of the digits and i'.
Any body have answer for this question
Geek is a spy in an enemy town. There are N
people in the town and every person has a
unique natural number that denotes their
identification. The ith person's identification
code is i. His organisation has however,
planted several allies in the town. They can
be identified by their identification code as
the digits in their codes form the smallest
possible permutation. Given N, find out how
many allies Geek has in the town.
Example 1:
Input: N = 13 Output: 12 Explanation:
Identification codes of Geek's allies are 1, 2,
3, 4, 5, 6, 7, 8, 9, 11, 12 and 13. Person with
Identification code 10 cannot be an ally as 10
is not the smallest permutation of the digits
'0' and '1'.
Example 2:
Input: N = 500 Output: 184
Your Task:
You dont need to read input or print anything.
Complete the function ally() that takes n as
input parameter and returns the number of
allies Geek has in enemy town.
Constraints: 1 ≤ N ≤ 9*1017
import java.util.*;
import java.lang.*;
import java.io.*;
/* Name of the class has to be "Main" only if the class is
public. */
class Codechef
{
public static void main (String[] args) throws
java.lang.Exception
{
// your code goes here
Scanner sc = new Scanner(System.in);
int num =sc.nextInt();
int max=0;
for(int i=10;i>0;i--){
if(num%i == 0){
System.out.println(i);
break;
}
else{
continue;
}
}
}
}
}
}
}
}
import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class Codechef { public static void main (String[] args) throws java.lang.Exception { // your code goes here Scanner sc = new Scanner(System.in); int num =sc.nextInt(); int max=0; for(int i=10;i>0;i--){ if(num%i == 0){ System.out.println(i); break; } else{ continue; } } } } } } } }