Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Bitnami MediaWiki
Search
Search
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
3237 - GCDnot1
Page
Discussion
English
Read
Edit
Edit source
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
Edit source
View history
General
What links here
Related changes
Special pages
Page information
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Cerinta == Se dau '''m''' şi '''n''' numere naturale nenule. Să se determine două numere naturale '''a''' şi '''b''' astfel încât '''c.m.m.d.c.(a + i , b + j) > 1''' pentru orice i = 0 , m-1 şi orice j = 0 , n-1. == Date de intrare == Programul citește de la tastatură numerele '''m''' şi '''n'''. == Date de iesire == Programul va afișa pe ecran numerele '''a''' şi '''b'''. == Restrictii si precizari == *1 ⩽ m , n ⩽ 5 *numerele a şi b vor avea cel mult 18 cifre fiecare == Exemplul 1 == ;Intrare :1 2 ;Iesire :Datele introduse corespund restrictiilor impuse :6 14 == Exemplul 2 == ;Intrare :0 100 ;Iesire :Datele introduse nu corespund restrictiilor impuse == Rezolvare == <syntaxhighlight lang="python3" line="1"> def este_prim(numar): if numar < 2: return False for i in range(2, int(numar ** 0.5) + 1): if numar % i == 0: return False return True def gaseste_numere_prime(m, n): for a in range(2, 1000): for b in range(a + 1, a + 1000): if all(este_prim(a) and este_prim(b) and este_prim(a + n) and este_prim(b + m) and este_prim(a + i) and este_prim(b + j) for i in range(m) for j in range(n)): return a, b # Citire date de intrare m = int(input("Introduceți m: ")) n = int(input("Introduceți n: ")) # Găsire numere a și b a, b = gaseste_numere_prime(m, n) # Afișare rezultat print(f"Numerele a și b sunt: {a}, {b}") </syntaxhighlight> == Explicatie == Avem (6 , 14) = 2 > 1 şi (6 , 15) = 3 > 1.
Summary:
Please note that all contributions to Bitnami MediaWiki may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Bitnami MediaWiki:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)
Toggle limited content width