Computer Science, asked by sivantkedia510913, 11 months ago

wap to accept a number and display those digits of the number which are the factors of 5 in java

Answers

Answered by sampathdudekula
1

Answer:

class factors

{

static void main()

{

   

 

    int a=5;

    System.out.print("\n");

    System.out.print("The factors are : ");

    for(int i=1;i<=a/2;i++)

    {

        if(a%i==0)

        System.out.print(i+",");

       }

       System.out.print(a);

   }

}

Answered by StaceeLichtenstein
0

Following are the program that is mention below.

Explanation:

import java.util.*; // import package

public class Main // main class

{

public static void main(String[] args) // main method

{

Scanner sc4=new Scanner(System.in); // scanner class

System.out.println("Enter the terms you want:");

int num1 = sc4.nextInt();//  read input by user

int k; // variable declaration

for(k=5;k<=num1;k++) //iterating the loop

{

   if(k%5==0) // checking condition

   {

     System.out.print(" " +k); // display value

   }

}  

}

}

Output:

Enter the terms you want: 50

5 10 15 20 25 30 35 40 45 50

Following are the description of program

  • Create the object of scanner class in sc4 which is used for taking user input.
  • Read the input in "num1" variable by the user.
  • Itearting the loop and display the number which is factor of 5 by using the if statement .

Learn More:

  • brainly.in/question/2323394

Similar questions