-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPerUf.java
More file actions
57 lines (42 loc) · 843 Bytes
/
PerUf.java
File metadata and controls
57 lines (42 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
// find the permutation using Formula =n!/(n-r)!
//where r-> number of letters
// FAILD
import java.util.*;
public class PerUf
{
public static void main(String args[])
{
int i,n;
String s;
Scanner sc=new Scanner(System.in);
System.out.println("Enter a String : ");
s=sc.nextLine();
char a[]=s.toCharArray();
n=a.length;
//System.out.println("Length of the Char= "+n);
// find factorial of length
int f=1;
for(i=1;i<=n;i++)
{
f=f*i;
}
System.out.println("Factorial of n= "+f);
// count the letters from string
int r=1;
char temp;
for(i=0;i<n;i++)
{
for(int j=0;j<f;j++)
{
if(a[i+1]!=a[j-1])
{
temp=a[i];
a[j]=a[i];
a[i]=temp;
}
System.out.print(""+a[i]);
}
System.out.println("Value of r = "+a[i]);
}
}
}