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
0977- Numere5
(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> #0977 - Numere5 def validate_constraints(n, k, p): if not (3 <= n <= 100 and 0 <= k <= 9 and 1 <= p <= 2000000000): print("Nu au fost respectate cerintele impuse.") return False return True def is_prime(num): if num < 2: return False for i in range(2, int(num**0.5) + 1): if num % i == 0: return False return True def sum_of_primes_in_sequence(n, sequence): primes_sum = 0 for i in range(n): if is_prime(sequence[i]): primes_sum += sequence[i] return primes_sum def count_digit_k_in_sequence(n, k, sequence): digit_count = 0 for i in range(n): digit_count += str(sequence[i]).count(str(k)) return digit_count def find_pth_term(p): a, b = 1, 2 for _ in range(p - 2): a, b = b, (a + b) % 10 return b # Citire date de intrare n, k, p = map(int, input("Introduceti valorile pentru n, k si p: ").split()) # Verificare restricții if not validate_constraints(n, k, p): exit() # Construirea șirului sequence = [1, 2] for _ in range(2, n): sequence.append((sequence[-1] + sequence[-2]) % 10) # Calculul rezultatelor result_a = sum_of_primes_in_sequence(n, sequence) result_b = count_digit_k_in_sequence(n, k, sequence) result_c = find_pth_term(p) # Afisarea rezultatelor print(result_a) print(result_b) print(result_c) </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