Advertisement
Guest User

Foobar

a guest
Jul 25th, 2021
261
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 13.65 KB | None | 0 0
  1. primes = [Dec('2'), Dec('3'), Dec('5'), Dec('7'), Dec('11'), Dec('13'), Dec('17'), Dec('19'), Dec('23'), Dec('29'), Dec('31'), Dec('37'), Dec('41'), Dec('43'), Dec('47'), Dec('53'), Dec('59'), Dec('61'), Dec('67'), Dec('71'), Dec('73'), Dec('79'), Dec('83'), Dec('89'), Dec('97'), Dec('101'), Dec('103'), Dec('107'), Dec('109'), Dec('113'), Dec('127'), Dec('131'), Dec('137'), Dec('139'), Dec('149'), Dec('151'), Dec('157'), Dec('163'), Dec('167'), Dec('173'), Dec('179'), Dec('181'), Dec('191'), Dec('193'), Dec('197'), Dec('199'), Dec('211'), Dec('223'), Dec('227'), Dec('229'), Dec('233'), Dec('239'), Dec('241'), Dec('251'), Dec('257'), Dec('263'), Dec('269'), Dec('271'), Dec('277'), Dec('281'), Dec('283'), Dec('293'), Dec('307'), Dec('311'), Dec('313'), Dec('317'), Dec('331'), Dec('337'), Dec('347'), Dec('349'), Dec('353'), Dec('359'), Dec('367'), Dec('373'), Dec('379'), Dec('383'), Dec('389'), Dec('397'), Dec('401'), Dec('409'), Dec('419'), Dec('421'), Dec('431'), Dec('433'), Dec('439'), Dec('443'), Dec('449'), Dec('457'), Dec('461'), Dec('463'), Dec('467'), Dec('479'), Dec('487'), Dec('491'), Dec('499'), Dec('503'), Dec('509'), Dec('521'), Dec('523'), Dec('541'), Dec('547'), Dec('557'), Dec('563'), Dec('569'), Dec('571'), Dec('577'), Dec('587'), Dec('593'), Dec('599'), Dec('601'), Dec('607'), Dec('613'), Dec('617'), Dec('619'), Dec('631'), Dec('641'), Dec('643'), Dec('647'), Dec('653'), Dec('659'), Dec('661'), Dec('673'), Dec('677'), Dec('683'), Dec('691'), Dec('701'), Dec('709'), Dec('719'), Dec('727'), Dec('733'), Dec('739'), Dec('743'), Dec('751'), Dec('757'), Dec('761'), Dec('769'), Dec('773'), Dec('787'), Dec('797'), Dec('809'), Dec('811'), Dec('821'), Dec('823'), Dec('827'), Dec('829'), Dec('839'), Dec('853'), Dec('857'), Dec('859'), Dec('863'), Dec('877'), Dec('881'), Dec('883'), Dec('887'), Dec('907'), Dec('911'), Dec('919'), Dec('929'), Dec('937'), Dec('941'), Dec('947'), Dec('953'), Dec('967'), Dec('971'), Dec('977'), Dec('983'), Dec('991'), Dec('997'), Dec('1009'), Dec('1013'), Dec('1019'), Dec('1021'), Dec('1031'), Dec('1033'), Dec('1039'), Dec('1049'), Dec('1051'), Dec('1061'), Dec('1063'), Dec('1069'), Dec('1087'), Dec('1091'), Dec('1093'), Dec('1097'), Dec('1103'), Dec('1109'), Dec('1117'), Dec('1123'), Dec('1129'), Dec('1151'), Dec('1153'), Dec('1163'), Dec('1171'), Dec('1181'), Dec('1187'), Dec('1193'), Dec('1201'), Dec('1213'), Dec('1217'), Dec('1223'), Dec('1229'), Dec('1231'), Dec('1237'), Dec('1249'), Dec('1259'), Dec('1277'), Dec('1279'), Dec('1283'), Dec('1289'), Dec('1291'), Dec('1297'), Dec('1301'), Dec('1303'), Dec('1307'), Dec('1319'), Dec('1321'), Dec('1327'), Dec('1361'), Dec('1367'), Dec('1373'), Dec('1381'), Dec('1399'), Dec('1409'), Dec('1423'), Dec('1427'), Dec('1429'), Dec('1433'), Dec('1439'), Dec('1447'), Dec('1451'), Dec('1453'), Dec('1459'), Dec('1471'), Dec('1481'), Dec('1483'), Dec('1487'), Dec('1489'), Dec('1493'), Dec('1499'), Dec('1511'), Dec('1523'), Dec('1531'), Dec('1543'), Dec('1549'), Dec('1553'), Dec('1559'), Dec('1567'), Dec('1571'), Dec('1579'), Dec('1583'), Dec('1597'), Dec('1601'), Dec('1607'), Dec('1609'), Dec('1613'), Dec('1619'), Dec('1621'), Dec('1627'), Dec('1637'), Dec('1657'), Dec('1663'), Dec('1667'), Dec('1669'), Dec('1693'), Dec('1697'), Dec('1699'), Dec('1709'), Dec('1721'), Dec('1723'), Dec('1733'), Dec('1741'), Dec('1747'), Dec('1753'), Dec('1759'), Dec('1777'), Dec('1783'), Dec('1787'), Dec('1789'), Dec('1801'), Dec('1811'), Dec('1823'), Dec('1831'), Dec('1847'), Dec('1861'), Dec('1867'), Dec('1871'), Dec('1873'), Dec('1877'), Dec('1879'), Dec('1889'), Dec('1901'), Dec('1907'), Dec('1913'), Dec('1931'), Dec('1933'), Dec('1949'), Dec('1951'), Dec('1973'), Dec('1979'), Dec('1987'), Dec('1993'), Dec('1997'), Dec('1999'), Dec('2003'), Dec('2011'), Dec('2017'), Dec('2027'), Dec('2029'), Dec('2039'), Dec('2053'), Dec('2063'), Dec('2069'), Dec('2081'), Dec('2083'), Dec('2087'), Dec('2089'), Dec('2099'), Dec('2111'), Dec('2113'), Dec('2129'), Dec('2131'), Dec('2137'), Dec('2141'), Dec('2143'), Dec('2153'), Dec('2161'), Dec('2179'), Dec('2203'), Dec('2207'), Dec('2213'), Dec('2221'), Dec('2237'), Dec('2239'), Dec('2243'), Dec('2251'), Dec('2267'), Dec('2269'), Dec('2273'), Dec('2281'), Dec('2287'), Dec('2293'), Dec('2297'), Dec('2309'), Dec('2311'), Dec('2333'), Dec('2339'), Dec('2341'), Dec('2347'), Dec('2351'), Dec('2357'), Dec('2371'), Dec('2377'), Dec('2381'), Dec('2383'), Dec('2389'), Dec('2393'), Dec('2399'), Dec('2411'), Dec('2417'), Dec('2423'), Dec('2437'), Dec('2441'), Dec('2447'), Dec('2459'), Dec('2467'), Dec('2473'), Dec('2477'), Dec('2503'), Dec('2521'), Dec('2531'), Dec('2539'), Dec('2543'), Dec('2549'), Dec('2551'), Dec('2557'), Dec('2579'), Dec('2591'), Dec('2593'), Dec('2609'), Dec('2617'), Dec('2621'), Dec('2633'), Dec('2647'), Dec('2657'), Dec('2659'), Dec('2663'), Dec('2671'), Dec('2677'), Dec('2683'), Dec('2687'), Dec('2689'), Dec('2693'), Dec('2699'), Dec('2707'), Dec('2711'), Dec('2713'), Dec('2719'), Dec('2729'), Dec('2731'), Dec('2741'), Dec('2749'), Dec('2753'), Dec('2767'), Dec('2777'), Dec('2789'), Dec('2791'), Dec('2797'), Dec('2801'), Dec('2803'), Dec('2819'), Dec('2833'), Dec('2837'), Dec('2843'), Dec('2851'), Dec('2857'), Dec('2861'), Dec('2879'), Dec('2887'), Dec('2897'), Dec('2903'), Dec('2909'), Dec('2917'), Dec('2927'), Dec('2939'), Dec('2953'), Dec('2957'), Dec('2963'), Dec('2969'), Dec('2971'), Dec('2999'), Dec('3001'), Dec('3011'), Dec('3019'), Dec('3023'), Dec('3037'), Dec('3041'), Dec('3049'), Dec('3061'), Dec('3067'), Dec('3079'), Dec('3083'), Dec('3089'), Dec('3109'), Dec('3119'), Dec('3121'), Dec('3137'), Dec('3163'), Dec('3167'), Dec('3169'), Dec('3181'), Dec('3187'), Dec('3191'), Dec('3203'), Dec('3209'), Dec('3217'), Dec('3221'), Dec('3229'), Dec('3251'), Dec('3253'), Dec('3257'), Dec('3259'), Dec('3271'), Dec('3299'), Dec('3301'), Dec('3307'), Dec('3313'), Dec('3319'), Dec('3323'), Dec('3329'), Dec('3331'), Dec('3343'), Dec('3347'), Dec('3359'), Dec('3361'), Dec('3371'), Dec('3373'), Dec('3389'), Dec('3391'), Dec('3407'), Dec('3413'), Dec('3433'), Dec('3449'), Dec('3457'), Dec('3461'), Dec('3463'), Dec('3467'), Dec('3469'), Dec('3491'), Dec('3499'), Dec('3511'), Dec('3517'), Dec('3527'), Dec('3529'), Dec('3533'), Dec('3539'), Dec('3541'), Dec('3547'), Dec('3557'), Dec('3559'), Dec('3571'), Dec('3581'), Dec('3583'), Dec('3593'), Dec('3607'), Dec('3613'), Dec('3617'), Dec('3623'), Dec('3631'), Dec('3637'), Dec('3643'), Dec('3659'), Dec('3671'), Dec('3673'), Dec('3677'), Dec('3691'), Dec('3697'), Dec('3701'), Dec('3709'), Dec('3719'), Dec('3727'), Dec('3733'), Dec('3739'), Dec('3761'), Dec('3767'), Dec('3769'), Dec('3779'), Dec('3793'), Dec('3797'), Dec('3803'), Dec('3821'), Dec('3823'), Dec('3833'), Dec('3847'), Dec('3851'), Dec('3853'), Dec('3863'), Dec('3877'), Dec('3881'), Dec('3889'), Dec('3907'), Dec('3911'), Dec('3917'), Dec('3919'), Dec('3923'), Dec('3929'), Dec('3931'), Dec('3943'), Dec('3947'), Dec('3967'), Dec('3989'), Dec('4001'), Dec('4003'), Dec('4007'), Dec('4013'), Dec('4019'), Dec('4021'), Dec('4027'), Dec('4049'), Dec('4051'), Dec('4057'), Dec('4073'), Dec('4079'), Dec('4091'), Dec('4093'), Dec('4099'), Dec('4111'), Dec('4127'), Dec('4129'), Dec('4133'), Dec('4139'), Dec('4153'), Dec('4157'), Dec('4159'), Dec('4177'), Dec('4201'), Dec('4211'), Dec('4217'), Dec('4219'), Dec('4229'), Dec('4231'), Dec('4241'), Dec('4243'), Dec('4253'), Dec('4259'), Dec('4261'), Dec('4271'), Dec('4273'), Dec('4283'), Dec('4289'), Dec('4297'), Dec('4327'), Dec('4337'), Dec('4339'), Dec('4349'), Dec('4357'), Dec('4363'), Dec('4373'), Dec('4391'), Dec('4397'), Dec('4409'), Dec('4421'), Dec('4423'), Dec('4441'), Dec('4447'), Dec('4451'), Dec('4457'), Dec('4463'), Dec('4481'), Dec('4483'), Dec('4493'), Dec('4507'), Dec('4513'), Dec('4517'), Dec('4519'), Dec('4523'), Dec('4547'), Dec('4549'), Dec('4561'), Dec('4567'), Dec('4583'), Dec('4591'), Dec('4597'), Dec('4603'), Dec('4621'), Dec('4637'), Dec('4639'), Dec('4643'), Dec('4649'), Dec('4651'), Dec('4657'), Dec('4663'), Dec('4673'), Dec('4679'), Dec('4691'), Dec('4703'), Dec('4721'), Dec('4723'), Dec('4729'), Dec('4733'), Dec('4751'), Dec('4759'), Dec('4783'), Dec('4787'), Dec('4789'), Dec('4793'), Dec('4799'), Dec('4801'), Dec('4813'), Dec('4817'), Dec('4831'), Dec('4861'), Dec('4871'), Dec('4877'), Dec('4889'), Dec('4903'), Dec('4909'), Dec('4919'), Dec('4931'), Dec('4933'), Dec('4937'), Dec('4943'), Dec('4951'), Dec('4957'), Dec('4967'), Dec('4969'), Dec('4973'), Dec('4987'), Dec('4993'), Dec('4999'), Dec('5003'), Dec('5009'), Dec('5011'), Dec('5021'), Dec('5023'), Dec('5039'), Dec('5051'), Dec('5059'), Dec('5077'), Dec('5081'), Dec('5087'), Dec('5099'), Dec('5101'), Dec('5107'), Dec('5113'), Dec('5119'), Dec('5147'), Dec('5153'), Dec('5167'), Dec('5171'), Dec('5179'), Dec('5189'), Dec('5197'), Dec('5209'), Dec('5227'), Dec('5231'), Dec('5233'), Dec('5237'), Dec('5261'), Dec('5273'), Dec('5279'), Dec('5281'), Dec('5297'), Dec('5303'), Dec('5309'), Dec('5323'), Dec('5333'), Dec('5347'), Dec('5351'), Dec('5381'), Dec('5387'), Dec('5393'), Dec('5399'), Dec('5407'), Dec('5413'), Dec('5417'), Dec('5419'), Dec('5431'), Dec('5437'), Dec('5441'), Dec('5443'), Dec('5449'), Dec('5471'), Dec('5477'), Dec('5479'), Dec('5483'), Dec('5501'), Dec('5503'), Dec('5507'), Dec('5519'), Dec('5521'), Dec('5527'), Dec('5531'), Dec('5557'), Dec('5563'), Dec('5569'), Dec('5573'), Dec('5581'), Dec('5591'), Dec('5623'), Dec('5639'), Dec('5641'), Dec('5647'), Dec('5651'), Dec('5653'), Dec('5657'), Dec('5659'), Dec('5669'), Dec('5683'), Dec('5689'), Dec('5693'), Dec('5701'), Dec('5711'), Dec('5717'), Dec('5737'), Dec('5741'), Dec('5743'), Dec('5749'), Dec('5779'), Dec('5783'), Dec('5791'), Dec('5801'), Dec('5807'), Dec('5813'), Dec('5821'), Dec('5827'), Dec('5839'), Dec('5843'), Dec('5849'), Dec('5851'), Dec('5857'), Dec('5861'), Dec('5867'), Dec('5869'), Dec('5879'), Dec('5881'), Dec('5897'), Dec('5903'), Dec('5923'), Dec('5927'), Dec('5939'), Dec('5953'), Dec('5981'), Dec('5987'), Dec('6007'), Dec('6011'), Dec('6029'), Dec('6037'), Dec('6043'), Dec('6047'), Dec('6053'), Dec('6067'), Dec('6073'), Dec('6079'), Dec('6089'), Dec('6091'), Dec('6101'), Dec('6113'), Dec('6121'), Dec('6131'), Dec('6133'), Dec('6143'), Dec('6151'), Dec('6163'), Dec('6173'), Dec('6197'), Dec('6199'), Dec('6203'), Dec('6211'), Dec('6217'), Dec('6221'), Dec('6229'), Dec('6247'), Dec('6257'), Dec('6263'), Dec('6269'), Dec('6271'), Dec('6277'), Dec('6287'), Dec('6299'), Dec('6301'), Dec('6311'), Dec('6317'), Dec('6323'), Dec('6329'), Dec('6337'), Dec('6343'), Dec('6353'), Dec('6359'), Dec('6361'), Dec('6367'), Dec('6373'), Dec('6379'), Dec('6389'), Dec('6397'), Dec('6421'), Dec('6427'), Dec('6449'), Dec('6451'), Dec('6469'), Dec('6473'), Dec('6481'), Dec('6491'), Dec('6521'), Dec('6529'), Dec('6547'), Dec('6551'), Dec('6553'), Dec('6563'), Dec('6569'), Dec('6571'), Dec('6577'), Dec('6581'), Dec('6599'), Dec('6607'), Dec('6619'), Dec('6637'), Dec('6653'), Dec('6659'), Dec('6661'), Dec('6673'), Dec('6679'), Dec('6689'), Dec('6691'), Dec('6701'), Dec('6703'), Dec('6709'), Dec('6719'), Dec('6733'), Dec('6737'), Dec('6761'), Dec('6763'), Dec('6779'), Dec('6781'), Dec('6791'), Dec('6793'), Dec('6803'), Dec('6823'), Dec('6827'), Dec('6829'), Dec('6833'), Dec('6841'), Dec('6857'), Dec('6863'), Dec('6869'), Dec('6871'), Dec('6883'), Dec('6899'), Dec('6907'), Dec('6911'), Dec('6917'), Dec('6947'), Dec('6949'), Dec('6959'), Dec('6961'), Dec('6967'), Dec('6971'), Dec('6977'), Dec('6983'), Dec('6991'), Dec('6997'), Dec('7001'), Dec('7013'), Dec('7019'), Dec('7027'), Dec('7039'), Dec('7043'), Dec('7057'), Dec('7069'), Dec('7079'), Dec('7103'), Dec('7109'), Dec('7121'), Dec('7127'), Dec('7129'), Dec('7151'), Dec('7159'), Dec('7177'), Dec('7187'), Dec('7193'), Dec('7207'), Dec('7211'), Dec('7213'), Dec('7219'), Dec('7229'), Dec('7237'), Dec('7243'), Dec('7247'), Dec('7253'), Dec('7283'), Dec('7297'), Dec('7307'), Dec('7309'), Dec('7321'), Dec('7331'), Dec('7333'), Dec('7349'), Dec('7351'), Dec('7369'), Dec('7393'), Dec('7411'), Dec('7417'), Dec('7433'), Dec('7451'), Dec('7457'), Dec('7459'), Dec('7477'), Dec('7481'), Dec('7487'), Dec('7489'), Dec('7499'), Dec('7507'), Dec('7517'), Dec('7523'), Dec('7529'), Dec('7537'), Dec('7541'), Dec('7547'), Dec('7549'), Dec('7559'), Dec('7561'), Dec('7573'), Dec('7577'), Dec('7583'), Dec('7589'), Dec('7591'), Dec('7603'), Dec('7607'), Dec('7621'), Dec('7639'), Dec('7643'), Dec('7649'), Dec('7669'), Dec('7673'), Dec('7681'), Dec('7687'), Dec('7691'), Dec('7699'), Dec('7703'), Dec('7717'), Dec('7723'), Dec('7727'), Dec('7741'), Dec('7753'), Dec('7757'), Dec('7759'), Dec('7789'), Dec('7793'), Dec('7817'), Dec('7823'), Dec('7829'), Dec('7841'), Dec('7853'), Dec('7867'), Dec('7873'), Dec('7877'), Dec('7879'), Dec('7883'), Dec('7901'), Dec('7907'), Dec('7919')]
  2.  
  3.  
  4. def factor(p):
  5.   i = 0
  6.   factors = []
  7.   current = p
  8.   while i < len(primes):
  9.     #keep dividing it, until it cant be divided anymore, and THEN increment index
  10.     if (current/primes[i])%1 < Dec('0.000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000001'):
  11.       factors.append(primes[i])
  12.       current = current/primes[i]
  13.     else:
  14.       i = i + 1
  15.  
  16.  
  17.   #print(("current: " + str(current)[:32] + ",  factors: " + str(factors)))
  18.   #return current, factors
  19.   return factors
  20.  
  21.  
  22. i = 1
  23. result = p
  24. _ = p
  25. while result >= 0:
  26.   _ = result - (i*3)
  27.   if _ < 0:
  28.     print("done!")
  29.     break
  30.   #else
  31.   result = _
  32.   #                                j
  33.   print(f"result: {result},  i: {i*3}")
  34.   if _ == (a**2) or _ == a or _ == b or _ == a+1 or _ == a+2 or _ == a+3 or _ == a-1 or _ == a-2 or _ == a-3:
  35.     print("found result!")
  36.     break
  37.   #else
  38.   _ = i*3
  39.   if _ == (a**2) or _ == a or _ == b or _ == a+1 or _ == a+2 or _ == a+3 or _ == a-1 or _ == a-2 or _ == a-3:
  40.     print("found result!")
  41.     break
  42.  
  43.   i = i + 1
  44.  
  45. z = p/(p-result)
  46.  
  47. #p/z will always been an integer
  48. factor(p/z)
  49.  
  50.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement