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
4226 - Divizibil
(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!
== Rezolvare == <syntaxhighlight lang="python" line> #4226 def calculeaza_rezultatul(cerinta, n, a=0, b=0, c=0): rezultat = n if cerinta == 1: rezultat = rezultat - (n // a) - (n // b) rezultat = rezultat + (n // (a * b)) elif cerinta == 2: rezultat = rezultat - (n // a) - (n // b) - (n // c) rezultat = rezultat + (n // (a * b)) + (n // (b * c)) + (n // (a * c)) rezultat = rezultat - (n // (a * b * c)) return rezultat def validate_cerinta(cerinta): if cerinta not in [1, 2]: print("Datele introduse nu corespund cerintelor.") return False return True def validate_n(n): if not 1 <= n <= 1000000000: print("Datele introduse nu corespund cerintelor.") return False return True def validate_variabila(variabila): if not 2 <= variabila <= 9: print("Datele introduse nu corespund cerintelor.") return False return True def validate_a_b_c(a, b, c): if not all([is_prime(i) for i in [a, b, c]]): print("Datele introduse nu corespund cerintelor.") return False return True def is_prime(n): if n < 2: return False for i in range(2, int(n**0.5)+1): if n % i == 0: return False return True if __name__ == '__main__': print("Introduceți cerința:") cerinta = int(input()) if not validate_cerinta(cerinta): exit() print("Introduceți numărul total:") n = int(input()) if not validate_n(n): exit() if cerinta == 1: print("Introduceți a:") a = int(input()) print("Introduceți b:") b = int(input()) if not all([validate_variabila(i) for i in [a, b]]): exit() rezultat = calculeaza_rezultatul(cerinta, n, a, b) elif cerinta == 2: print("Introduceți a:") a = int(input()) print("Introduceți b:") b = int(input()) print("Introduceți c:") c = int(input()) if not all([validate_variabila(i) for i in [a, b, c]]): exit() if not validate_a_b_c(a, b, c): exit() rezultat = calculeaza_rezultatul(cerinta, n, a, b, c) else: rezultat = n print("Datele introduse corespund cerintelor.\n",rezultat) </syntaxhighlight>
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