Showing posts with label amicable-pair-number. Show all posts
Showing posts with label amicable-pair-number. Show all posts

Friday, August 7, 2020

Write a program to input a number and check whether it is Amicable Pair Number or not?(220,284|| sum of factors of 220 is equal to 284 and sum of factors of 284 is equal to 220 then it is amicable pair Number)

81)  Write a program to input a number and check whether it is Amicable Pair Number or not?(220,284|| sum of factors of 220 is equal to 284 and sum of factors of 284 is equal to 220 then it is amicable pair Number) 


import java.util.*;
public class Amicable_pair_num
{
    public static void main(String args[ ])
   {
           Scanner sc = new Scanner (System.in);
           System.out.println("Enter two numbers");
           int a = sc.nextInt();
           int b = sc.nextInt();
           int m = 0;
           int n = 0;
           for(int i = 1;i<a;i++)
           {
               if(a%i==0)
               {
                   m=m+i;
               }
           }
           for(int i = 1;i<b;i++)
           {
               if(b%i==0)
               {
                   n=n+i;
               }
           }
           if(m==b&&n==a)
           {
               System.out.println("Entered number are AMICABLE PAIR Number ");
           }
           else
           {
               System.out.println("Entered number are not AMICABLE PAIR Number ");
           }
    }

 jhvghvgk ;nkjn ,nkjhj