#include <iostream> using namespace std; int yinzizhihe(int a){ int b = 0; for(int i = 1;i<a;i++){ if(a%i==0){ b = b+i; } } return b; } int main(){ int a = 4; int sum1 = 0; int b = 0; while(1){ b = yinzizhihe(a); sum1 = yinzizhihe(b); if(a==sum1 && b!=sum1){ cout<<a<<" "<<b; break; } a++; } return 0; }
标签:std,int,yinzizhihe,namespace,using,亲和数 From: https://www.cnblogs.com/wangyanbo111/p/17080109.html