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 ");}}}
Output :
amicable-pair-number Write a program to input a number and
Swap the first and last digit of
this number?(2784===4782) |
No comments:
Post a Comment
if you have any doubts, Please let me know.
Your Truly
Shashank Porwal