• Breaking News

    For Loop ব্যবহার করে মৌলিক সংখ্যা নির্ণয়ের জাভা প্রোগ্রাম লেখো

    For Loop ব্যবহার করে মৌলিক সংখ্যা নির্ণয়ের জাভা প্রোগ্রাম লেখো


    প্রোগ্রামের সোর্স কোড-


    import java.util.Scanner;
    public class PrimeCheck
    {
       public static void main(String args[])
       {              
              int temp;
              boolean isPrime=true;
              Scanner scan= new Scanner(System.in);
              System.out.println("Enter the number you want to check:");
              int num=scan.nextInt();
            scan.close();
              for(int i=2;i<=num/2;i++)
              {
               temp=num%i;
                 if(temp==0)
                 {
                    isPrime=false;
                    break;
                 }
              }
              if(isPrime)
                 System.out.println(num + " is a Prime Number");
              else
                 System.out.println(num + " is not a Prime Number");
       }
    }
     
    প্রোগ্রামটি রান করলে যে আউটপুট পাবো তা হলো:
    Enter the number you want to check:
    11
    11 is a Prime Number

    পরবর্তী প্রোগ্রাম- 

    No comments