java program to print odd factors of a number
PLS GIVE CORRECT PROGRAM
LS GIVE IT FAST
Share
java program to print odd factors of a number
PLS GIVE CORRECT PROGRAM
LS GIVE IT FAST
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Verified answer
Required Answer:-
Question:
Solution:
Here is the program.
import java.util.*;
public class OddFactors {
public static void main(String[] args) {
Scanner sc=new Scanner(System.in);
System.out.print("Enter the number: ");
int n=sc.nextInt();
System.out.println("Odd factors are...");
for(int i=1;i<=n;i+=2) {
if(n%i==0)
System.out.print(i+" ");
}
sc.close();
}
}
Explanation:
Output is attached.