This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
What am I doing wrong in here? HELP by 10:30 EST 10/27/99
- To: help-gcc at gnu dot org
- Subject: What am I doing wrong in here? HELP by 10:30 EST 10/27/99
- From: isaacpetro at my-deja dot com
- Date: Thu, 28 Oct 1999 01:20:19 GMT
- Newsgroups: gnu.gcc.help
- Organization: Deja.com - Before you buy.
- Xref: wodc7nx0 gnu.gcc.help:1624
Hey folks... I can't see WHAT i am doing wrong here... any help or
direction would be much appreciated, this one is going down to the
wire...
/****************************************************
*Programmer: Isaac Petruccelli *
*Date: 10/27/99 *
*File: perfect.h *
*Description: This declares the function IsPerfect.*
****************************************************/
extern IsPerfect ( int count );
/****************************************
*Programmer: Isaac Petruccelli *
*Date: 10/27/99 *
*File: main.c *
*Description: This file will call scan *
*a number from the command line *
*and find all perfect numbers between *
*1 and that number. *
****************************************/
#include <stdlib.h>
#include <stdio.h>
#include "perfect.h"
int main( int argc, char *argv[] ) {
int n;
int count;
int x;
int z;
/*The number from the command line is being stored as an integer type
via the atoi function*/
n=atoi( argv[1]);
for( count=2; count<n; count++){
IsPerfect ( count );
if ( z==count )
printf ("%d", count) ;
}
return (0);
}
/*************************************************************
*Programmer: Isaac Petruccelli *
*Date: 10/27/99 *
*File: perfect.c *
*Description: This file uses a for loop, testing all proper*
*divisors up to the number entered from the command line, *
*starting with the divisor 1. *
************************************************************/
int IsPerfect ( int count ){
int i;
int x;
int z;
z=1;
for ( i=1; i<=n/2; i++ )
{
if (count%i==0)
z=z+i ;
}
return (z);
}
Sent via Deja.com http://www.deja.com/
Before you buy.