-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDiffIntFactorTriplet.py
More file actions
29 lines (23 loc) · 974 Bytes
/
DiffIntFactorTriplet.py
File metadata and controls
29 lines (23 loc) · 974 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# MIT License (see the licence in the repo for details)
# Copyright (c) 2018 Félix An
# This script is used to find 3 DIFFERENT positive or negative factors for a given number.
targetNo = int(input("Target Number to find factor triplets? Must be a positive integer -> "))
int1 = targetNo * -1
int2 = targetNo * -1
int3 = targetNo * -1
print("Starting query for target " + str(targetNo) + ", all three factors will be different...")
import time
startTime = time.time()
while int3 <= targetNo:
if int1 * int2 * int3 == targetNo and int1 != int2 and int2 != int3 and int1 != int3:
print(str(int1) + " * " + str(int2) + " * " + str(int3) + " = " + str(targetNo))
if int1 > targetNo:
int2 = int2 + 1
int1 = targetNo * -1
else:
int1 = int1 + 1
if int2 > targetNo:
int3 = int3 + 1
int2 = targetNo * -1
print("Elapsed time: approximately " + str(time.time() - startTime) + " seconds")
print("*** FINISHED ***")