Computer Science Canada Programming C, C++, Java, PHP, Ruby, Turing, VB   Username:   Password: Wiki   Blog   Search   Turing   Chat Room  Members
Does log exist in Turing?
Author Message
not_l33t

Posted: Thu May 27, 2004 6:03 pm   Post subject: Does log exist in Turing?

I have to convert the prime number theorm into Turing. There fore I need log (math) command, or something of that function. I am trying to make a program for listing prime numbers.

Catalyst

Posted: Thu May 27, 2004 6:19 pm   Post subject: (No subject)

 code: function log (b : int, x : real) : real     result (ln (x) / ln (b)) end log
not_l33t

Posted: Thu May 27, 2004 6:36 pm   Post subject: (No subject)

 code: % The factoring program % Declare varibles. var integer : int % Ask user to input the integer. put "Please enter a integer between 1 and 50: " .. get integer % Output factors for the integer. put "Here are all the factors for ", integer, ":" put "1 " .. % Use loops to get factors continuesly. loop     if integer mod 2 = 0     % used to get factors.             then         put 2, " " ..         integer := integer div 2     % After get factor 2, continue to get the next factor.     end if     exit when integer mod 2 not= 0 end loop loop     if integer mod 3 = 0             then         put 3, " " ..         integer := integer div 3     end if     exit when integer mod 3 not= 0 end loop loop     if integer mod 5 = 0             then         put 5, " " ..         integer := integer div 5     end if     exit when integer mod 5 not= 0 end loop loop     if integer mod 7 = 0             then         put 7, " " ..         integer := integer div 7     end if     exit when integer mod 7 not= 0 end loop loop     if integer mod 11 = 0             then         put 11, " " ..         integer := integer div 11     end if     exit when integer mod 11 not= 0 end loop loop     if integer mod 13 = 0             then         put 13, " " ..         integer := integer div 13     end if     exit when integer mod 13 not= 0 end loop loop     if integer mod 17 = 0             then         put 17, " " ..         integer := integer div 17     end if     exit when integer mod 17 not= 0 end loop loop     if integer mod 19 = 0             then         put 19, " " ..         integer := integer div 19     end if     exit when integer mod 19 not= 0 end loop loop     if integer mod 23 = 0             then         put 23, " " ..         integer := integer div 23     end if     exit when integer mod 23 not= 0 end loop loop     if integer mod 29 = 0             then         put 29, " " ..         integer := integer div 29     end if     exit when integer mod 31 not= 0 end loop loop     if integer mod 31 = 0             then         put 31, " " ..         integer := integer div 31     end if     exit when integer mod 31 not= 0 end loop loop     if integer mod 37 = 0             then         put 37, " " ..         integer := integer div 37     end if     exit when integer mod 37 not= 0 end loop loop     if integer mod 41 = 0             then         put 41, " " ..         integer := integer div 41     end if     exit when integer mod 41 not= 0 end loop loop     if integer mod 43 = 0             then         put 43, " " ..         integer := integer div 43     end if     exit when integer mod 43 not= 0 end loop loop     if integer mod 47 = 0             then         put 47, " " ..         integer := integer div 47     end if     exit when integer mod 47 not= 0 end loop

I was looking over my program, I wonder if this could be converted to out put only prime numbers.
Tony

Posted: Thu May 27, 2004 11:32 pm   Post subject: (No subject)

prime numbers
Tony's programming blog. DWITE - a programming contest.
AsianSensation

Posted: Fri May 28, 2004 3:14 pm   Post subject: (No subject)

believe me, I am crying....

Though I don't get why you are using logarithms if you want to display prime numbers....
 Display posts from previous: All Posts1 Day7 Days2 Weeks1 Month3 Months6 Months1 Year Oldest FirstNewest First

Page 1 of 1  [ 5 Posts ]
 Jump to:  Select a forum  CompSci.ca ------------ - Network News - General Discussion     General Forums   -----------------   - Hello World   - Featured Poll   - Contests     Contest Forums   -----------------   - DWITE   - [FP] Contest 2006/2008   - [FP] 2005/2006 Archive   - [FP] 2004/2005 Archive   - Off Topic     Lounges   ---------   - User Lounge   - VIP Lounge     Programming -------------- - General Programming     General Programming Forums   --------------------------------   - Functional Programming   - Logical Programming   - C     C   --   - C Help   - C Tutorials   - C Submissions   - C++     C++   ----   - C++ Help   - C++ Tutorials   - C++ Submissions   - Java     Java   -----   - Java Help   - Java Tutorials   - Java Submissions   - Ruby     Ruby   -----   - Ruby Help   - Ruby Tutorials   - Ruby Submissions   - Turing     Turing   --------   - Turing Help   - Turing Tutorials   - Turing Submissions   - PHP     PHP   ----   - PHP Help   - PHP Tutorials   - PHP Submissions   - Python     Python   --------   - Python Help   - Python Tutorials   - Python Submissions   - Visual Basic and Other Basics     VB   ---   - Visual Basic Help   - Visual Basic Tutorials   - Visual Basic Submissions     Education ----------- - Student Life   Graphics and Design ----------------------- - Web Design     Web Design Forums   ---------------------   - (X)HTML Help   - (X)HTML Tutorials   - Flash MX Help   - Flash MX Tutorials   - Graphics     Graphics Forums   ------------------   - Photoshop Tutorials   - The Showroom   - 2D Graphics   - 3D Graphics     Teams ------ - dTeam Public

 Style: Appalachia blueSilver eMJay subAppalachia subBlue subCanvas subEmjay subGrey subSilver subVereor Search: