]> git.proxmox.com Git - mirror_edk2.git/blobdiff - AppPkg/Applications/Python/Python-2.7.2/Demo/scripts/fact.py
edk2: Remove AppPkg, StdLib, StdLibPrivateInternalFiles
[mirror_edk2.git] / AppPkg / Applications / Python / Python-2.7.2 / Demo / scripts / fact.py
diff --git a/AppPkg/Applications/Python/Python-2.7.2/Demo/scripts/fact.py b/AppPkg/Applications/Python/Python-2.7.2/Demo/scripts/fact.py
deleted file mode 100644 (file)
index 2068c85..0000000
+++ /dev/null
@@ -1,49 +0,0 @@
-#! /usr/bin/env python\r
-\r
-# Factorize numbers.\r
-# The algorithm is not efficient, but easy to understand.\r
-# If there are large factors, it will take forever to find them,\r
-# because we try all odd numbers between 3 and sqrt(n)...\r
-\r
-import sys\r
-from math import sqrt\r
-\r
-def fact(n):\r
-    if n < 1:\r
-        raise ValueError('fact() argument should be >= 1')\r
-    if n == 1:\r
-        return []  # special case\r
-    res = []\r
-    # Treat even factors special, so we can use i += 2 later\r
-    while n % 2 == 0:\r
-        res.append(2)\r
-        n //= 2\r
-    # Try odd numbers up to sqrt(n)\r
-    limit = sqrt(n+1)\r
-    i = 3\r
-    while i <= limit:\r
-        if n % i == 0:\r
-            res.append(i)\r
-            n //= i\r
-            limit = sqrt(n+1)\r
-        else:\r
-            i += 2\r
-    if n != 1:\r
-        res.append(n)\r
-    return res\r
-\r
-def main():\r
-    if len(sys.argv) > 1:\r
-        source = sys.argv[1:]\r
-    else:\r
-        source = iter(raw_input, '')\r
-    for arg in source:\r
-        try:\r
-            n = int(arg)\r
-        except ValueError:\r
-            print arg, 'is not an integer'\r
-        else:\r
-            print n, fact(n)\r
-\r
-if __name__ == "__main__":\r
-    main()\r