Guest Posted July 8, 2010 Report Share Posted July 8, 2010 Determine the probability that for a base ten positive integer x chosen at random from 1 to 9999 inclusively, this relationship is satisfied: (sod(x))2 = x+2, where sod(n) denotes the sum of the digits in the base ten representation of n. Quote Link to comment Share on other sites More sharing options...
0 Guest Posted July 8, 2010 Report Share Posted July 8, 2010 7 out of 9999 They are 2, 23, 62, 119, 194, 287, and 398 Quote Link to comment Share on other sites More sharing options...
0 unreality Posted July 8, 2010 Report Share Posted July 8, 2010 public static void sumofdigitslinear(int cap) { System.out.println("~~~CAP "+cap); int numSatisfy = 0; for (int i=1; i<=cap; i++) { if (sodsquared(i) == i+2) { numSatisfy++; System.out.println(i); } } System.out.println("~~~~~\n\n\t"+numSatisfy+" out of "+cap); System.out.println("\t"+((double)numSatisfy/(double)cap)); } public static int sodsquared(int x) { int con = 0; while (x > 0) { con += (x % 10); x /= 10; } return con*con; } ~~~CAP 9999 2 23 62 119 194 287 398 ~~~~~ 7 out of 9999 7.000700070007E-4 Quote Link to comment Share on other sites More sharing options...
0 Guest Posted July 8, 2010 Report Share Posted July 8, 2010 2, 62, 119, 194, 287, 398. So 6/9999 or .0006 repeating Quote Link to comment Share on other sites More sharing options...
0 Guest Posted July 8, 2010 Report Share Posted July 8, 2010 forgot 23, so 7/9999 Quote Link to comment Share on other sites More sharing options...
Question
Guest
Determine the probability that for a base ten positive integer x chosen at random from 1 to 9999 inclusively, this relationship is satisfied:
(sod(x))2 = x+2, where sod(n) denotes the sum of the digits in the base ten representation of n.
Link to comment
Share on other sites
4 answers to this question
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.