-
Notifications
You must be signed in to change notification settings - Fork 0
/
factorizate.c
45 lines (41 loc) · 891 Bytes
/
factorizate.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <stdio.h>
#include <stdlib.h>
#include <malloc.h>
#include "list.h"
///////////firse method///////////
/*
* please see the function:
* factorizate in gcd.c
*/
//////////second method//////////
/*
* first we find the prime smaller
* than the m( which is factorizated )
*/
void
getPrime( int m, linkList *l )
{
int i = 0, j = 0;
int length;
int e;
for( ; i<=m-2; i++ ) {
e=i+2;
enList(l, e); //Make sure the begin number is 2
}
printf( "get Prime" );
length = listLength( l );
printf ("The length is:%d\n", length);
printList( l );
for ( j=1; j<=5; j++ ) {
e = 2*(j+1);
deListByElement( l, 2*j );
}
printList( l );
}
int main(int argc, char *argv[])
{
linkList *l = ( linkList* )malloc( sizeof( linkList ) );
initList( l );
getPrime( 2, l );
return 0;
}