Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <script>
- var liczba;
- function LICZBA_PIERWSZA(liczba) {
- var count = 0;
- for (let i = 1; i <= liczba; i++) {
- if (liczba%i == 0) {
- count = count + 1;
- }
- }
- if (count == 2) {
- return 1;
- }
- else {
- return 0;
- }
- }
- function check(liczba) {
- if (LICZBA_PIERWSZA(liczba) == 1) {
- document.write(liczba+ " jest liczbą pierwszą<br>");
- }
- else {
- document.write(liczba+ " nie jest liczbą pierwszą<br>");
- }
- }
- check(7);
- check(6);
- check(23);
- </script>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement