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
3512 - Factorial Query
(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="1"> # 3512 - Factorial Query def validare_date(n, numere): # Verificăm dacă n se află între 1 și 1.000.000 if n < 1 or n > 1000000: return False # Verificăm dacă fiecare număr din listă este mai mic sau egal cu 10.000.000 for numar in numere: if numar > 10000000: return False # Datele sunt corecte return True def factorial(n): # Returnează factorialul lui n, redus modular la 1.000.000.007 produs = 1 for i in range(1, n + 1): produs = (produs * i) % 1000000007 return produs def main(): # Citim numărul n de la tastatură n_input = input("Introduceti numarul n: ") if not n_input: print("Introduceti un numar n mai mare decat 0.") return n = int(n_input) # Citim cele n numere de la tastatură numere_input = input("Introduceti cele n numere, separate prin spatiu: ") if not numere_input: print("Introduceti cel putin un numar.") return numere = list(map(int, numere_input.split())) # Validăm datele de intrare if not validare_date(n, numere): print("Datele nu corespund restricțiilor impuse.") return # Calculăm produsul factorialelor și îl reducem modular la 1.000.000.007 produs = 1 for numar in numere: produs = (produs * factorial(numar)) % 1000000007 # Afișăm rezultatul print("Datele sunt introduse corect.") print(f"Produsul factorialelor este: {produs}") if __name__ == "__main__": main() </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