Menu Close

Determine the encryption key

Write an algorithm to determine the encryption key.
The input consists of an integer – numMessage, representing the numeric form of the message.
The Output prints an integer representing the encryption key
Note: Digits 1 and 0 are considered as a prime number

num=int(input("Enter the Number = "))
temp=num
s=0
while(temp!=0):
	c=temp%10
	d=0
	for i in range(2,10):
		if c%i==0 and c!=i:
			d=d+1
			break
		else:
			d=d+0
	if d!=0 and c!=0 and c!=1:
		s=s+c
	temp=int(temp/10)
print(s)

Sample
Input:
            45673
Output:
            10
Explanation: The non-prime digits are 4 and 6. Hence, the output is 4+6=10


Output:
Enter the Number = 45673
10

Output:
Enter the Number = 56895
23

Output:
Enter the Number = 562151
6

Output:
Enter the Number = 10020
0

Output:
Enter the Number = 56000
6

Output:
Enter the Number = 123456
10

Output:
Enter the Number = 98765432
27


More Codes to Fcuk

data-ad-client=”ca-pub-7546515534599219″ data-ad-slot=”8812323733″ data-ad-format=”auto” data-full-width-responsive=”true”>

Explore