Untitled

 avatar
dibya
plain_text
a year ago
2.3 kB
1
Indexable
Never
import java.util.Scanner;
public class projone {
    
    public static void main(String[]args){
        
        //task 1 
        System.out.println("Task 1:");
        for(int asc=1; asc<=10;asc++){
            System.out.println(asc);
        }
        System.out.println();
        int des=10;
        while(des>=1){
            System.out.println(des);
            des--;
        }

        //Task 2
        System.out.println("Task 2:");
        for(int ev=0;ev<101;ev++){
            if(ev%2==0){
                System.out.println(ev);
            }
        }

        //task 3
        System.out.println("Task 3:");
        for(int i=1;i<=100;i++){
            if(i%2==0){
                System.out.println(i);
            }
        }

        //Task 4
        System.out.println("Task 4:");
        int numb, temp=0;
        Scanner scan=new Scanner(System.in);
        numb= scan.nextInt();
        if(numb==0|| numb==1){
            System.out.println("Not a prime number \n");
        }
        else{
            for(int i=2;i<numb;i++){
                if(numb%i==0){
                    temp=2;
                    break;
                }
                else{
                    temp=1;
                }
                if(temp==1){
                    System.out.println("Prime number \n");
                }
                if(temp==2){
                    System.out.println("Not a prime number \n");
                }
            }
        }

        //Task5
        System.out.println("Task 5:");
        for(int i=1;i<=100;i++){
            if(i%3==0 && i%5==0){
                System.out.println(i+"\t FizzBuzz");
            }
            if(i%5==0){
                System.out.Println(i+"\t Buzz");
            }
            if(i%3==0){
                System.out.println(i+"\t Fizz");
            }
            else if(i%3!=0 || i%5!=0){
                System.out.println(i);
            }
        }

        //task 6
        System.out.println("Task 6:");
        int fin,numb=25,t1=0,t2=1,nt=0;
        nt=t1+t2;
        for(int i=3;i<=numb;i++){    
            t1=t2;
            t2=nt;
            nt=t1+t2;
        }
        fin=nt;
        System.out.println(fin);
    }
    
}