All pastes #413980 Raw Edit

Stuff

public text v1 · immutable
#413980 ·published 2007-03-28 20:10 UTC
rendered paste body
/*
 $Author: sitexec $
 $Date: 2007/03/29 02:34:02 $
 $Revision: 1.5 $
 $Header: /home/sitexec/cvs/sitexec/dir/As6/As6.c,v 1.5 2007/03/29 02:34:02 sitexec Exp $
*/
#include <stdio.h>

void findFactor(unsigned long n, unsigned long *pF);

void factor(unsigned long n)
{

	unsigned long f;
	do
	{
		findFactor(n, &f);
		printf("%d\n",f);
		n /= f;
	}
	while (n > 1);
}

void findFactor(unsigned long n, unsigned long *pF)
{
// write this subroutine in assembly
// it should utilize isAFactorOf
// assume n >= 2
// when findFactor returns, *pF should be a prime factor of n

int factor,i;
	for(i = n; i < n; i++)
	{
		factor = isAFactorOf(n, *pF);
		if(factor == 0)
		{
			i = n;
		}
	}

}

int isAFactorOf(unsigned long f, unsigned long n)
{

return n % f == 0;

}

int main(void)
{

unsigned long x;
scanf("%u",&x);
factor(x);
return 0;

}