Group Abstract Group Abstract

Message Boards Message Boards

0
|
3.2K Views
|
5 Replies
|
0 Total Likes
View groups...
Share
Share this post:

using Do,If,ModPprint

Posted 11 years ago

Find all numbers from 1 to 30 which are not multiples of 2 or 5 using Do,If,Mod,Print

POSTED BY: sam adams
5 Replies

Study the following code carefully don't hand it in until you (a) understand each point and can explain why each piece does what it does and (b) in a separate notebook you can recreate it from scratch:

Do[
 If[(Mod[n, 2] == 0) || (Mod[n, 5] == 0), Print[n]],
 {n, 1, 30}
 ]
POSTED BY: David Reiss
Posted 11 years ago

ok I understand what each of do,if,mod and print but im struggling to use them correctly this is what I have come up with so far

Print[Do[If {Mod[{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}, 2, 5]}, n > 0, 0], {n, 30}]

POSTED BY: sam adams
POSTED BY: David Reiss
Posted 11 years ago
POSTED BY: sam adams

What have you tried? It's probably not in the cards to use this forum to have us do your homework for you ;-)

POSTED BY: David Reiss
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard