import java.util.*;
class Arr
{
int arr[];
int i,j,n,m,no,c,max;
Scanner sc=new Scanner(System.in);
public void show()
{
System.out.print("\nHow many elements:");
n=sc.nextInt();
arr=new int[n];
for(i=0;i<n;i++)
{
System.out.print("\nValue:");
arr[i]=sc.nextInt();
}
max=0;
System.out.print("\nValues=");
for(i=0;i<n;i++)
System.out.print(" "+arr[i]);
for(i=0;i<n;i++)
{
no=arr[i];
c=0;
for(j=1;j<=no;j++)
{
if(no%j==0)
c++;
}
if(c>max)
{
max=c;
m=no;
}
}
System.out.print("\nNumber with maximum factors="+m + " and number of factors "+max);
}
}
class Arr
{
int arr[];
int i,j,n,m,no,c,max;
Scanner sc=new Scanner(System.in);
public void show()
{
System.out.print("\nHow many elements:");
n=sc.nextInt();
arr=new int[n];
for(i=0;i<n;i++)
{
System.out.print("\nValue:");
arr[i]=sc.nextInt();
}
max=0;
System.out.print("\nValues=");
for(i=0;i<n;i++)
System.out.print(" "+arr[i]);
for(i=0;i<n;i++)
{
no=arr[i];
c=0;
for(j=1;j<=no;j++)
{
if(no%j==0)
c++;
}
if(c>max)
{
max=c;
m=no;
}
}
System.out.print("\nNumber with maximum factors="+m + " and number of factors "+max);
}
}
No comments:
Post a Comment