forked from ghostmkg/programming-language
- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSpy_Recur.java
More file actions
Latest commit
38 lines (35 loc) · 800 Bytes
/
Copy pathSpy_Recur.java
File metadata and controls
38 lines (35 loc) · 800 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
importjava.util.*;
classSpy_Recur
{
intspy(intn,ints,intp)
{
intc=0;
if(n==0)
{
if(s==p)
return1;
return0;
}
else
{
c=n%10;
s=s+c;
p=p*c;
n=n/10;
returnspy(n,s,p);
}
}
publicstaticvoidmain()
{
Scannersc=newScanner(System.in);
Spy_Recurob=newSpy_Recur();
intno,p;
System.out.println("Enter a no.");
no=sc.nextInt();
p=ob.spy(no,0,1);
if(p==1)
System.out.print("Spy no.");
else
System.out.print("Not Spy");
}
}