18-Section-Handout

# 18-Section-Handout - CS106A Handout 18 April 20th 2011...

This preview shows pages 1–2. Sign up to view the full content.

CS106A Handout 18 Spring 2011 April 20 th , 2011 Section Handout Discussion Problem 1: Ostentatious Numbers Provide an implementation for a method that returns true if the provided number is an ostentatious number , and false otherwise. An ostentatious number is a positive integer equal or nearly equal to product of its own digit sum and its own digit product (and by nearly equal, we mean that the original number and the constructed product differ by no more than 10.) (Negative numbers are never ostentatious, and zero isn’t ostentatious either.) As an example, 135 is an ostentatious number, because 135 equals (1 + 3 + 5)(1 * 3 * 5) = 9 * 15 = 135 8633 is also ostentatious, because its digit-sum-digit-product product is (8 + 6 + 3 + 3)(8 * 6 * 3 * 3) = 20 * 432 = 8640, and 8640 is only 7 more than the original 8633. Implement the isOstentatiousNumber method, which accepts an arbitrary integer— possibly negative—and returns true if and only if the supplied number is ostentatious. private boolean isOstentatiousNumber(int n) { Discussion Problem 2: Tipping Point Probability Write a full ConsoleProgram that’s similar to the six-consecutive-coin-flips example

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 05/28/2011 for the course CS 106A taught by Professor Sahami,m during the Spring '08 term at Stanford.

### Page1 / 6

18-Section-Handout - CS106A Handout 18 April 20th 2011...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online