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
2329 - prim007
(section)
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!
==Explicaţie cod== Functia '''este_prim(n)''' - Verifica daca un numar este prim sau nu. Daca numarul este mai mic decat 2, functia va returna False, altfel, va verifica daca numarul are un divizor in intervalul '''[2, sqrt(n)]'''. Daca il gaseste, functia va returna False, altfel, va returna True. Functia '''prim007(n, vector)''' - Primeste un numar '''n''' si un vector de numere '''vector'''. Functia itereaza prin toate perechile de numere din '''vector''', calculeaza suma lor si verifica daca suma este un numar prim prin apelarea functiei '''este_prim(n)'''. Daca suma este un numar prim, va incrementa un contor. La final, functia va afisa valoarea contorului. Functia '''conform_restrictiilor(n, vector)''' - Verifica daca valorile primite ca input respecta restrictiile impuse de problema. Verifica daca '''n''' este intre 2 si 100000, iar valorile din vector sunt mai mici sau egale cu 10000. Daca valorile respecta restrictiile, functia va returna True, altfel, va afisa un mesaj de eroare si va returna False. In functia '''main''', programul primeste input-ul, verifica daca acesta respecta restrictiile impuse prin apelarea functiei '''conform_restrictiilor(n, vector)''' si, daca este cazul, calculeaza si afiseaza numarul de perechi de numere din '''vector''' a caror suma este un numar prim prin apelarea functiei '''prim007(n, vector)'''.
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