Exemplo n.º 1
0
int main(void) {
    for (int i=1; i<=10000; i++) {
        if (isPerfect(i)) {
            printf("%d is perfect!\n", i);
        }
    }
    return EXIT_SUCCESS;
}
Exemplo n.º 2
0
void printPerfects()
{
  int n = 1, p;
  printf("Perfect numbers are: ");
  for( n = 1 ; n <= 1000 ; n++ ){
    p = isPerfect( n );
    if( p == 1)
      printf("%d ", n);
  }
}
Exemplo n.º 3
0
int main(void) {

	int k;

	for(k=1;k<=10000;k++) {
		if(isPerfect(k)) {
			printf("%d\n",k);
		}
	}
	return 0;
}
Exemplo n.º 4
0
int main() 
{
  int num, p;
  printf("Please enter a number: ");
 scanf("%d", &num);
 p = isPerfect(num);
 if( p == 1 )
   printf("%d is perfect.\n", num);
 else if( p == 2 )
   printf("%d is not perfect.\n", num);
 printPerfects();
 printf("\n");
 return 0;
}
Exemplo n.º 5
0
int main(){
  unsigned long int number;
  int i;
  while(scanf("%ld",&number) && number){
    if(number==1)
      printf("yes\n");
    else if(number==2)
      printf("no\n");
    else{
      if(isPerfect(number))
	       printf("yes\n");
      else
	       printf("no\n");
    }
  }
  return 0;
}
Exemplo n.º 6
0
int main(int argc, const char *argv[]) {
    std::cout << "Program to test whether a number is perfect or not\n"
              << std::endl;

    std::cout << "Perfect number between 1 and 100: " << std::endl;
    for (long i = 1; i <= 100000000000; i++) {
        // print perfect numbers
        if (isPerfect(i)) {
            std::cout << i << ":"
                      << "\t";
            // print divisors
            for (long d = 1; d < i; d++) {
                if (i % d == 0) { std::cout << d << " "; }
            }
            std::cout << std::endl;
        }
    }

    std::cout << std::endl;
    return 0;
}