Write a program in Java to input 10 integer elements in an
array. Display only perfect number from array elements
Answers
Answered by
2
Answer:
import java. util. Scanner; class Perfect.
{ public static void main(String arg[])
{ long n,sum=0;
Scanner sc=new Scanner(System. in); System. out. println("Enter a number");
n=sc. nextLong(); int i=1;
while(i<=n/2) {
if(n%i==0) {
sum+=i; }
Similar questions
English,
4 months ago
Physics,
8 months ago
Social Sciences,
8 months ago
Hindi,
1 year ago
Science,
1 year ago