Printing Ordered Pairs

Problem Statement
Write a C program that reads a positive integer
n and prints all pairs (unordered) of {a,b} so
that
(1/n)=(1/a)+(1/b)
#include<stdio.h> int main() { int n,sq,p,q; printf("enter thew value of n \n"); scanf("%d",&n); sq=n*n; for(p=1;p<=sq/2;p++) { if(sq%p==0) { q=sq/p; printf("%d ,%d \n",p+n,q+n); } } return 0; }



No comments:

Post a Comment