Computer Science, asked by sangpthdr3184, 1 year ago

Write a program in Java to accept a number and display it's highest factor(except itself).

Answers

Answered by AnshJaaiswalAj
0
import java.util.*;
class greatest factor
{
public static void main (String args[ ])
{
Scanner sc=new Scanner (System.in);
System.out.println("enter number for calculating greatest factor");
int a=sc.nextInt( ) ;
int b=a-1;
int i;
for ( i=b; i<a;i--)
{
System.out.println("greatest factor is -"+i);
break;
}
}
}
}
Similar questions