Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // z.1
- const prompt=require('prompt-sync')();
- function bezw(x)
- {
- if(x>0)
- {
- return x;
- }
- else if(x<0)
- {
- return (-x);
- }
- }
- const x= +prompt ("Podaj liczbe: ");
- console.log(bezw(x));
- // z.2
- const prompt=require('prompt-sync')();
- function parzysta(x)
- {
- if (x%2==0)
- {
- return true;
- }
- else
- {
- return false;
- }
- }
- const x= +prompt ("Podaj liczbe: ");
- console.log(parzysta(x));
- // z.3
- const prompt=require('prompt-sync')();
- function podzielnosc(x,y)
- {
- let z=1;
- for (let i= 0;i<x-1;i++)
- {
- z*=10;
- }
- for (let i=z;i<z*10-1;i++)
- {
- if(i%y==0)
- {
- console.log(i);
- }
- }
- }
- const x= +prompt ("Podaj ilocyfrowe liczby: ");
- const y= +prompt ("Podaj dzielnik: ");
- console.log(podzielnosc(x,y));
- // z.4
- const prompt=require('prompt-sync')();
- function pierwsza(x)
- {
- if(x>=2)
- {
- for(let i=2;i*i<=x;i++)
- if(x%i==0)
- {
- return 0;
- }
- return 1;
- }
- else
- {
- return 0;
- }
- }
- const x= +prompt ("Podaj liczbe: ");
- if(pierwsza(x)==1)
- {
- console.log("Liczba pierwsza")
- }
- else if(pierwsza(x)==0)
- {
- console.log("Nie liczba pierwsza")
- }
- // z.5
- const prompt=require('prompt-sync')();
- function liczbacyfr(x)
- {
- x= x.toString();
- let i=0;
- i= x.length;
- return i;
- }
- const x= +prompt ("Podaj liczbe: ");
- console.log(liczbacyfr(x));
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement