Search found 17 matches
- Tue Apr 27, 2010 3:40 pm
- Forum: C/C++ Programming
- Topic: code help
- Replies: 5
- Views: 4657
code help
next one: i have found alla the primes (previous topic) and now i want in a list all the numbers (p^2^k)<=Upper limit where p the prime, k a nonnegative integer.. for example if upper limit is 24 then i want : [2,2^2=4,2^3=8,16,3,9,5,7,11,13,17,23] #include <stdio.h> #include <stdlib.h> #include <ma...
- Tue Apr 27, 2010 1:04 pm
- Forum: C/C++ Programming
- Topic: How find prime factors of a given number using C++
- Replies: 11
- Views: 12471
Re: How find prime factors of a given number using C++
There were some syntax & logical errors. However your effort on this made me do the correction for you ;) #include <stdio.h> #include <stdlib.h> typedef struct primes_ { int no; struct primes_ * next; } PrimesList; void main (){ int i, B = 1024, count, flag1; PrimesList *list, *temp, *initial; list...
- Tue Apr 27, 2010 4:16 am
- Forum: C/C++ Programming
- Topic: How find prime factors of a given number using C++
- Replies: 11
- Views: 12471
Re: How find prime factors of a given number using C++
ok.. can you tell me what is wrong with the code below.. #include <stdio.h> #include <stdlib.h> int main () { int flag=1,B=1024,n=1,count=3,flag1; struct primes { int no; struct primes * next; }; typedef struct primes PrimesList; PrimesList *list,*temp, *initial; list=(PrimesList*)malloc(sizeof(Prim...
- Thu Apr 22, 2010 5:40 am
- Forum: C/C++ Programming
- Topic: How find prime factors of a given number using C++
- Replies: 11
- Views: 12471
Re: How find prime factors of a given number using C++
This is because, we need i to be odd numbers... i starts from 3, then we make it 5, 7, 9, 11 ...... Since we have extracted all 2s from the original number, there is no point in making it a even number. but why not to extract alla the 3's,5's...that's why i mentioned use a list of prime factors... ...
- Tue Apr 20, 2010 8:12 pm
- Forum: C/C++ Programming
- Topic: How find prime factors of a given number using C++
- Replies: 11
- Views: 12471
Re: How find prime factors of a given number using C++
well i am not familiar with c++ but think i have understood the code above: i don't get that point of the code while (!(r & 1)) { printf("2\n"); r >>= 1; } and another one question: why i=i+2 and not proceed to the next prime.. because by adding 2 , you will also examine numbers that are not prime.....
- Tue Apr 20, 2010 12:03 am
- Forum: C/C++ Programming
- Topic: How find prime factors of a given number using C++
- Replies: 11
- Views: 12471
Re: How find prime factors of a given number using C++
thanks.. but at this time this is not my primary problem.. i will deal with it later.. :D what i have to do in the project is find for any number between 1 and 100.000.000 its largest prime factor.. what i ve done is construct a linked list of all the prime numbers and then check it's one number bet...
- Mon Apr 19, 2010 1:07 am
- Forum: C/C++ Programming
- Topic: How find prime factors of a given number using C++
- Replies: 11
- Views: 12471
Re: How find prime factors of a given number using C++
in order not to open new thread.. is this algorithm sufficient for large numbers?? for ie for n= 100.000.000..
i have found other algorithms such as quadratic sieve but i don't understand them so as to transfer them into code.. if anyone has heard them, can explain them?? thanks anyway..
i have found other algorithms such as quadratic sieve but i don't understand them so as to transfer them into code.. if anyone has heard them, can explain them?? thanks anyway..