You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Co-primes, while not being the most exciting thing in the world, are extremely useful for cryptography (among other things). Numbers are co-prime if they don't share any common factors above 1.
For example, 15 and 8 are not prime, but have factors of 3 5 and 2 4 respectively, and so are co-prime. 15 and 9 are not co-prime, since they share a factor of 3.
For your input number, what is the sum of the positive co-primes of that number which are less than that number?
For example, the coprimes of 15 are
1 2 4 7 8 11 13 14
If your input was 15, the answer would be 60.
GIVEN INPUT:-
===========
987820
ANSWER:-
======
q)
q)
q)
q)
q)co_prime:{a:(where 0=x mod (til x))except 1; l:til x; i:0; while[i<count a; c,:where 0= l mod (a i); i+:1]; v:l except (distinct c); sum v}