Alice Community Solving math problems with Programming

 Solving math problems with Programming
 hydude777 Member   Status: Offline Posts: 25 Join Date: Apr 2011 Solving math problems with Programming - 02-07-2012, 12:09 AM programmers! i need help on a math problem... is it okay to post here? Are there any prime numbers with differences of 3? e.g. 2 and 5 (they're not prime) is it possible to solve that with programming? For example to find if 'how many positive integers less than 1000 do not have 7 as their digit' private int doit() { int rwcnt=0; for (int i=0; i< 1000;i++) { string stri = Convert.ToString(i); if (stri.IndexOf("7") == -1) {rwcnt++;} } return rwcnt; } rwcnt = 729. that would work.
 x2495iiii Super Moderator     Status: Offline Posts: 3,508 Join Date: Dec 2008 Location: Somewhere in the Continental U.S. 02-07-2012, 02:48 AM 2 and 5 are prime and are the only prime numbers that are three apart. This is because all prime numbers are odd, and an odd number plus 3 makes an even number. 2 is the only even prime number, meaning two and five are the only prime numbers with a difference of three. (')>
 hydude777 Member   Status: Offline Posts: 25 Join Date: Apr 2011 02-07-2012, 07:47 AM oh, okay that was easy :O thanks for the explanation x2495iiii !!

 Thread Tools Display Modes Linear Mode

 Posting Rules You may not post new threads You may not post replies You may not post attachments You may not edit your posts BB code is On Smilies are On [IMG] code is On HTML code is Off Forum Rules
 Forum Jump User Control Panel Private Messages Subscriptions Who's Online Search Forums Forums Home Announcements     Community News and Announcements Alice 3     How Do I?     Works In Progress     Share Your World     Share Custom Classes     Bugs and Trouble Shooting     Suggestion Box Alice 2     How do I...?     Works-In-Progress     Share Worlds     Share Objects     Bugs and Troubleshooting     Suggestion Box Educators     Teaching with Alice     Teaching Using Alice 3     Teaching Using Alice 2     CS Principles and Alice     AP CSA and Intro to Java and Alice     Workshops General Discussion     Questions and Comments     The Lounge