13,149,756 members (78,970 online)

# Algorithms

 Re: Specify numbers as product of Primes? Paul Conrad28-Jun-08 6:11 Paul Conrad 28-Jun-08 6:11
 Re: Specify numbers as product of Primes? Ravi Bhavnani8-Aug-08 7:16 Ravi Bhavnani 8-Aug-08 7:16
 Re: Specify numbers as product of Primes? cp987628-Jun-08 20:27 cp9876 28-Jun-08 20:27
 Re: Specify numbers as product of Primes? Luc Pattyn29-Jun-08 2:42 Luc Pattyn 29-Jun-08 2:42
 Re: Specify numbers as product of Primes? MarkBrock27-Jun-08 18:46 MarkBrock 27-Jun-08 18:46
 Re: Specify numbers as product of Primes? Paul Conrad28-Jun-08 5:42 Paul Conrad 28-Jun-08 5:42
 Re: Specify numbers as product of Primes? ChandraRam2-Jul-08 22:49 ChandraRam 2-Jul-08 22:49
 Re: Specify numbers as product of Primes? MarkBrock2-Jul-08 23:06 MarkBrock 2-Jul-08 23:06
 Re: Specify numbers as product of Primes? Member 419459326-Jun-08 8:19 Member 4194593 26-Jun-08 8:19
 Re: Specify numbers as product of Primes? Robert.C.Cartaino26-Jun-08 8:47 Robert.C.Cartaino 26-Jun-08 8:47
 Re: Specify numbers as product of Primes? Ian Uy26-Jun-08 17:51 Ian Uy 26-Jun-08 17:51
 Re: Specify numbers as product of Primes? cp987629-Jun-08 14:57 cp9876 29-Jun-08 14:57
 Re: Specify numbers as product of Primes? Arash Partow29-Jun-08 0:48 Arash Partow 29-Jun-08 0:48
 Re: Specify numbers as product of Primes? [modified] cp987629-Jun-08 3:53 cp9876 29-Jun-08 3:53
  since Arash has completely changed the code in his previous post, this appears somewhat out of context [/edit] I think this is an example of misguided optimization. Whilst Ian Uy's example looks inefficient ```int main() { int InputCase; cin >> InputCase; for(int i=2;i<=InputCase;i++) { if(InputCase%i==0) { cout << i; InputCase/=i; i--; } } return 0; }``` all he is doing each iteration is testing ```if(InputCase%i==0) ``` In order to avoid these "unnecessary" tests, you are testing each n as ```if (n % 2 == 0) n++; while(!is_prime(n)) { ++n; } ``` The function is_prime(n) will involve much more overhead than the original code, and it doesn't matter that 'i' may not be prime. Peter "Until the invention of the computer, the machine gun was the device that enabled humans to make the most mistakes in the smallest amount of time." modified on Saturday, October 18, 2008 11:35 PM
 Re: Specify numbers as product of Primes? Luc Pattyn29-Jun-08 4:40 Luc Pattyn 29-Jun-08 4:40
 Re: Specify numbers as product of Primes? cp987629-Jun-08 14:47 cp9876 29-Jun-08 14:47
 Re: Specify numbers as product of Primes? Arash Partow30-Jun-08 2:54 Arash Partow 30-Jun-08 2:54
 Re: Specify numbers as product of Primes? cp987630-Jun-08 3:18 cp9876 30-Jun-08 3:18
 Re: Specify numbers as product of Primes? Arash Partow30-Jun-08 4:27 Arash Partow 30-Jun-08 4:27
 Re: Specify numbers as product of Primes? Arash Partow30-Jun-08 2:17 Arash Partow 30-Jun-08 2:17
 Polyline offset algorithm beko16-Jun-08 21:59 beko 16-Jun-08 21:59
 Re: Polyline offset algorithm Alan Balkany17-Jun-08 4:07 Alan Balkany 17-Jun-08 4:07
 Re: Polyline offset algorithm beko17-Jun-08 4:43 beko 17-Jun-08 4:43
 Re: Polyline offset algorithm CPallini17-Jun-08 7:03 CPallini 17-Jun-08 7:03
 Re: Polyline offset algorithm beko17-Jun-08 8:26 beko 17-Jun-08 8:26
 Re: Polyline offset algorithm cp987617-Jun-08 12:10 cp9876 17-Jun-08 12:10
 Re: Polyline offset algorithm Arash Partow18-Jun-08 1:22 Arash Partow 18-Jun-08 1:22
 Re: Polyline offset algorithm beko18-Jun-08 19:55 beko 18-Jun-08 19:55
 need similar to Excel's "Goal Seek" in C/C++ KimN6-May-08 9:04 KimN 6-May-08 9:04
 Re: need similar to Excel's "Goal Seek" in C/C++ 73Zeppelin6-May-08 9:17 73Zeppelin 6-May-08 9:17
 Re: need similar to Excel's "Goal Seek" in C/C++ KimN6-May-08 10:06 KimN 6-May-08 10:06
 Re: need similar to Excel's "Goal Seek" in C/C++ 73Zeppelin6-May-08 10:29 73Zeppelin 6-May-08 10:29
 Re: need similar to Excel's "Goal Seek" in C/C++ cp98766-May-08 15:57 cp9876 6-May-08 15:57
 Re: need similar to Excel's "Goal Seek" in C/C++ 73Zeppelin6-May-08 19:19 73Zeppelin 6-May-08 19:19
 how to convert a string to a mathematical function nta_388626-Sep-07 2:55 nta_3886 26-Sep-07 2:55
 Re: how to convert a string to a mathematical function DavidCrow26-Sep-07 4:48 DavidCrow 26-Sep-07 4:48
 Re: how to convert a string to a mathematical function dan neely26-Sep-07 5:25 dan neely 26-Sep-07 5:25
 Re: how to convert a string to a mathematical function El Corazon26-Sep-07 9:45 El Corazon 26-Sep-07 9:45
 Re: how to convert a string to a mathematical function Russell'27-Sep-07 0:35 Russell' 27-Sep-07 0:35
 Re: how to convert a string to a mathematical function Urs Enzler27-Sep-07 1:16 Urs Enzler 27-Sep-07 1:16
 Re: how to convert a string to a mathematical function Luc Pattyn27-Sep-07 3:29 Luc Pattyn 27-Sep-07 3:29
 Re: how to convert a string to a mathematical function PICguy9-Oct-07 20:57 PICguy 9-Oct-07 20:57
 Numerical Recipes in C# Bassam Abdul-Baki31-Oct-06 5:18 Bassam Abdul-Baki 31-Oct-06 5:18
 Re: Numerical Recipes in C# djlove31-Oct-06 22:42 djlove 31-Oct-06 22:42
 Message Closed 9-Mar-16 21:32 Member 12380023 9-Mar-16 21:32
 Re: Numerical Recipes in C# Just me at will_george...something8-Nov-06 3:09 Just me at will_george...something 8-Nov-06 3:09
 Message Closed 9-Mar-16 21:32 Member 12380023 9-Mar-16 21:32
 Message Closed 9-Mar-16 21:32 Member 12380023 9-Mar-16 21:32
 fdfdsf Gul zeb13-Sep-06 21:43 Gul zeb 13-Sep-06 21:43
 Re: fdfdsf Ed.Poore14-Sep-06 1:04 Ed.Poore 14-Sep-06 1:04
 Last Visit: 31-Dec-99 18:00     Last Update: 25-Sep-17 7:12 Refresh « Prev1...192021222324 Next »