Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ZADANIE 1
- function wartoscBezwgledna (x){
- if(Number.isInteger(x)==false){
- return 'blad';}
- else{
- if(x>=0){
- return x;
- }
- else{
- const result=x* -1;
- return result;
- }
- }
- }
- document.write(wartoscBezwgledna(3),'<br>');
- document.write(wartoscBezwgledna(-32),'<br>');
- document.write(wartoscBezwgledna(0.6));
- ZADANIE 2
- function CzyParzysta (x){
- if(Number.isInteger(x)==false){
- return 'blad';}
- else{
- if(x%2==0){
- return true;
- }
- else{
- return false;
- }
- }
- }
- document.write( CzyParzysta(3),'<br>');
- document.write(CzyParzysta(-32),'<br>');
- document.write(CzyParzysta(0.6));
- ZADABUE 3
- function CzyParzysta (x,a){
- if(Number.isInteger(x,a)==false){
- return 'blad';}
- else{
- const wykładnik=x-1;
- var pierwsza =+(Math.pow(10, wykładnik));
- var druga =+(Math.pow(10, x));
- for(let d=pierwsza; d<druga;d++)
- {
- if (d%a==0){
- document.write(d,'<br>');
- }
- }
- }
- }
- var m=+prompt("wpisz ilo liczbowa liczba");
- var y=+prompt("wpisz przeco ma się dizelić");
- document.write( CzyParzysta(m,y),'<br>');
- ZADANIE 4
- function CzyParzysta (x){
- if(Number.isInteger(x)==false){
- return 'blad';}
- else{
- let y=x-1;
- if(x==2||x==1){
- return 1;
- }
- do {
- if (x%y==0){
- return 0;
- }
- y=y-1;
- }while(y>1)
- if(y==1 ){
- return 1;
- }
- }
- }
- var m=+prompt("wpisz liczba");
- if (CzyParzysta(m)==1){
- document.write ('pierwsza');
- }
- else
- {
- document.write ('nie pierwsza')
- }
- ZADNIE 5
- function liczbaCyfr (x){
- var y=0;
- do{
- x=x/10;
- y=y+1;
- }
- while(x>=0.1)
- return y-1;
- }
- var m=+prompt("wpisz liczba");
- document.write(liczbaCyfr(m));
Add Comment
Please, Sign In to add comment