Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- int main()
- {
- int n1,n2,i,j=0,a[1000],tong,k;
- scanf("%d %d",&n1,&n2);
- if (n1>n2)
- {
- for (k=n2;k<=n1;k++)//xet cac so hoan hao tu k =1 den n
- {
- tong=0;//reset cac bien ve 0
- j=0;
- for (i=1;i<k;i++)
- {
- if (k%i==0)//tim uoc cua k
- {
- a[j]=i;//sau do gan vao chuoi a
- j++;
- }
- }
- for (i=0;i<j;i++)//bien j=so uoc cua k vi j++ theo uoc
- tong+=a[i];//tong cua cac uoc
- if (tong==k)
- printf("%d ",tong);
- }
- }
- else if (n1<n2)
- {
- for (k=n1;k<=n2;k++)//xet cac so hoan hao tu k =1 den n
- {
- tong=0;//reset cac bien ve 0
- j=0;
- for (i=1;i<k;i++)
- {
- if (k%i==0)//tim uoc cua k
- {
- a[j]=i;//sau do gan vao chuoi a
- j++;
- }
- }
- for (i=0;i<j;i++)//bien j=so uoc cua k vi j++ theo uoc
- tong+=a[i];//tong cua cac uoc
- if (tong==k)
- printf("%d ",tong);
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement