• Keine Ergebnisse gefunden

is_prime = True

N/A
N/A
Protected

Academic year: 2021

Aktie " is_prime = True "

Copied!
1
0
0

Wird geladen.... (Jetzt Volltext ansehen)

Volltext

(1)

Python C++

limit = input("Upper limit:") limit = int(limit)

for candidate in range(2, limit + 1):

is_prime = True

for test in range(2, min(candidate,

limit // 2 + 1)):

if candidate % test == 0:

is_prime = False break

if is_prime:

print(candidate, "is a prime") else:

print(candidate, "is not a prime")

#include <iostream>

int main(int argc, char **argv) { std::cout << "Upper limit: ";

int limit;

std::cin >> limit;

for (int candidate = 2; candidate < limit + 1;

candidate++) { bool is_prime = true;

for (int test = 2; test < std::min(candidate, limit / 2 + 1); test++) {

if (candidate % test == 0) { is_prime = false;

break;

} }

if (is_prime) {

std::cout << candidate << " is a prime"

<< std::endl;

} else {

std::cout << candidate << " is not a prime"

<< std::endl;

}

} }

Referenzen

ÄHNLICHE DOKUMENTE

Prove the properties of the muiltiset ordering following definition 8.22 on slide 284..

Prove the properties of the muiltiset ordering following definition 8.22 on slide 284..

[r]

The inability of Arab societies to make a transition from authoritarian political systems to democratic ones has been explained in two ways: (1) as a result of religious and cultural

Nash-Sutcliffe efficiency don’t necessarily grant right results for the right

Die Instruktion check i überprüft, ob die (ungebundene) Variable oben auf dem Keller innerhalb des Term vorkommt, an den die Variable i gebunden ist.. Ist dies der Fall,

• For some sub-expressions, we obtain ⊤ :-).. Abstract evaluation of expressions is like the concrete evaluation — but with abstract values and operators. analogously for

Ein Recht zu haben heißt jedoch auch, ein Recht auf eine bestimmte Organisation der Gesellschaft zu ha- ben, welche das Recht schützt – dies gilt erst recht, wenn die