-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path27.py
42 lines (36 loc) · 790 Bytes
/
27.py
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
30
31
32
33
34
35
36
37
38
39
40
41
42
# -*- coding: utf-8 -*-
"""
Created on Sun Apr 26 23:18:07 2020
@author: santi
"""
def es_primo(n):
"""
Recibe un numero n y dice si es primo.
"""
if n <= 0:
return False
for i in range (2,n):
if n % i == 0:
return False
return True
def quadratic(a,b,n):
return n**2 + a*n + b
listaprimos = []
for i in range(1,1001):
if es_primo(i):
listaprimos.append(i)
maxa = 0
maxb = 0
contmax = 0
for i in listaprimos:
for a in [-i,i]:
for b in listaprimos:
cont = 0
n = 0
while es_primo(quadratic(-a,b,n)):
cont += 1
n += 1
if cont > contmax:
contmax = cont
maxa = a
maxb = b