-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathBoston Number.java
More file actions
78 lines (67 loc) · 1.48 KB
/
Boston Number.java
File metadata and controls
78 lines (67 loc) · 1.48 KB
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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
package Condingblockscodes;
import java.util.Scanner;
public class bostonnumber {
public static int primeFactors(long n)
{ int sum= 0 ;
while (n%2==0)
{
sum+=2;
n /= 2;
}
for (int i = 3; i <= Math.sqrt(n); i+= 2)
{
while (n%i == 0)
{
sum+=i;
n /= i;
}
}
if (n > 2)
sum+=n ;
return sum ;
}
public static void main(String[] args) {
Scanner scn = new Scanner(System.in) ;
long N= scn.nextLong();
int sod=0;
long temp=N ;
while(temp!=0)
{
sod+=temp%10;
temp/=10;
}
for(int i=2;i*i<=N;i++)
if(N%i==0)
{
int count=0;
while(N%i==0)
{
N/=i;
count++;
}
int sum=0;
temp=i;
while(temp!=0)
{
sum+=temp%10;
temp/=10;
}
sod-=sum*count;
}
if(N!=1)
{
int sum=0;
temp=N;
while(temp!=0)
{
sum+=temp%10;
temp/=10;
}
sod-=sum;
}
if(sod==0)
System.out.println("1");
else
System.out.println("0");
}
}