Solution verification for determining how many numbers in a set that are prime to a particular number

107 Views Asked by At

I have this problem: Find total numbers in the set contains integers from 0 to 799 that are relatively prime to 800.

My solution is: 800 - (numbers that are divisible by 2 or 5) = 800 - (400+160-80) = 320.

1

There are 1 best solutions below

0
On BEST ANSWER

Good job, the approach and the answer is correct.

Short python code to verify the answer:

def gcd(a, b):
    if b == 0:
        return a
    else:
        return gcd(b, a % b)
counter = 0  
for i in range(800):
    if gcd(i,800) == 1:
        counter += 1
print(counter)