avkLab

TestPrime

Jun 10th, 2022
140
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. # -*- coding: utf-8 -*-
  3. #----------------------------------------------------------------------------
  4. # Created by  : Alain Van Kerckhoven
  5. # Created Date: 6 mars 2017
  6. # Licence     : GPL
  7. # Version     : 1.0
  8. # ---------------------------------------------------------------------------
  9. """
  10. Teste pour une suite de nombre lesquels sont premiers.
  11. """
  12. # ---------------------------------------------------------------------------
  13.  
  14. for n in range(2, 100):
  15.     for x in range(2, n):
  16.         if n % x == 0:
  17.             print (n, 'equals', x, '*', n // x)
  18.             break
  19.     else:
  20.         # loop fell through without finding a factor
  21.         print (n, 'is a prime number')
  22.  
Add Comment
Please, Sign In to add comment