0 évaluation0% ont trouvé ce document utile (0 vote)
13 vues1 page
This document provides an algorithm to determine if a number n is prime by checking if the sum of all divisors of n that are less than n is greater than n. It uses a list comprehension to iterate from 1 to n-1, check if each x is a divisor of n by seeing if the modulo of n and x is 0, and if so adds x to the running sum. It then checks if this sum is greater than n to determine primality.
This document provides an algorithm to determine if a number n is prime by checking if the sum of all divisors of n that are less than n is greater than n. It uses a list comprehension to iterate from 1 to n-1, check if each x is a divisor of n by seeing if the modulo of n and x is 0, and if so adds x to the running sum. It then checks if this sum is greater than n to determine primality.
This document provides an algorithm to determine if a number n is prime by checking if the sum of all divisors of n that are less than n is greater than n. It uses a list comprehension to iterate from 1 to n-1, check if each x is a divisor of n by seeing if the modulo of n and x is 0, and if so adds x to the running sum. It then checks if this sum is greater than n to determine primality.