View Code of Problem 93

#include<stdio.h>
#include<math.h>
#include<string.h>
//#include<algorithm>
#include <bits/stdc++.h>

using namespace std;

int getsum(int n) {
	int i,j=n;
	int sum=1;
	for(i=2; i<j; i++) {
		if(n%i==0) {
			sum=sum+i;
			j=n/i;
			sum=sum+j;
		}
	}
	return sum;

}

int main() {
	int a,b;
	scanf("%d %d",&a,&b);
	int i,j,temp;
	for(i=a; i<=b; i++) {
		temp=getsum(i);
		if(temp<=b && temp>=a &&temp>i) {
			if(getsum(temp)==i) {
				printf("%d %d\n",i,temp);
			}
		}
	}


}

Double click to view unformatted code.


Back to problem 93