Moriarity
05-18-2010, 09:37 PM
Okies, not asking for anyone to do any homework for me, so let me get that out of the way quick.
What I am asking for is opinion.
Situation: In a class on programming logic we were to create a program for listing the primes from 1-100 with the function having been given to us earlier. I found, and pointed out, that his function was incorrect and would always return a MOD=0 and thus determine it to be a non prime for any number. He then announced in class that anyone who could write a program returning all the primes would receive extra points. So, my question to you folks is, should I fight for the extra points? Because while I didn't use typical math or the most efficient means I believe my logic is solid, although the actual writing might be wrong. (This doesn't matter, he only wanted the logic).
Sorry it is in pseudo code probably not used and I definitely need to improve, it is what we're being taught.
Thanks much. Sorry to ask here, but the pseudo code area seems deserted.
///PE10 Ch6//NAME//5-9-2010///
2 ///Program: Prime Numbers
3 Declare integer counter, counter1
4 Constant integer times = 100
5 Constant integer times1 = 9
6 Main module ()
7 Display "I will display the Prime numbers in the range of 1-100."
8 For counter = 1 to times
9 staus = getPrime(counter)
10 If status = True then
11 Display counter, "is a prime number."
12 End If
13 End For
14 End
15 Function boolean getPrime (Integer counter)
16 Declare Boolean status
17 Set status = true
18 For counter1 = 2 to times1
19 If counter MOD counter1 == 0 AND counter = 1 then
20 Return status
21 Else If counter MOD counter1 == 0 AND counter = 2 then
22 Return status
23 Else If counter MOD counter1 == 0 AND counter = 3 then
24 Return status
25 Else If counter MOD counter1 == 0 AND counter = 5 then
26 Return status
27 Else If counter MOD counter1 == 0 AND counter = 7 then
28 Return status
31 Else If counter MOD counter1 == 0
32 Set Status = False
33 Return status
34 Else
35 Set Status = True
36 Return status
37 End If
38 End If
39 End If
40 End If
41 End If
42 End If
43 End IF
44 End For
45 End Function
What I am asking for is opinion.
Situation: In a class on programming logic we were to create a program for listing the primes from 1-100 with the function having been given to us earlier. I found, and pointed out, that his function was incorrect and would always return a MOD=0 and thus determine it to be a non prime for any number. He then announced in class that anyone who could write a program returning all the primes would receive extra points. So, my question to you folks is, should I fight for the extra points? Because while I didn't use typical math or the most efficient means I believe my logic is solid, although the actual writing might be wrong. (This doesn't matter, he only wanted the logic).
Sorry it is in pseudo code probably not used and I definitely need to improve, it is what we're being taught.
Thanks much. Sorry to ask here, but the pseudo code area seems deserted.
///PE10 Ch6//NAME//5-9-2010///
2 ///Program: Prime Numbers
3 Declare integer counter, counter1
4 Constant integer times = 100
5 Constant integer times1 = 9
6 Main module ()
7 Display "I will display the Prime numbers in the range of 1-100."
8 For counter = 1 to times
9 staus = getPrime(counter)
10 If status = True then
11 Display counter, "is a prime number."
12 End If
13 End For
14 End
15 Function boolean getPrime (Integer counter)
16 Declare Boolean status
17 Set status = true
18 For counter1 = 2 to times1
19 If counter MOD counter1 == 0 AND counter = 1 then
20 Return status
21 Else If counter MOD counter1 == 0 AND counter = 2 then
22 Return status
23 Else If counter MOD counter1 == 0 AND counter = 3 then
24 Return status
25 Else If counter MOD counter1 == 0 AND counter = 5 then
26 Return status
27 Else If counter MOD counter1 == 0 AND counter = 7 then
28 Return status
31 Else If counter MOD counter1 == 0
32 Set Status = False
33 Return status
34 Else
35 Set Status = True
36 Return status
37 End If
38 End If
39 End If
40 End If
41 End If
42 End If
43 End IF
44 End For
45 End Function