id/email
password
forgot password | create account
about | help | code help+videos | done | prefs
CodingBat code practice

 

minPurchasesRequired


Disclaimer: Math-heavy question

------

A company has come up with a promotion where customers have a 1 in n chance of winning a prize (for every product purchased). n is in the range from 1 to 50. Define a function that when passed the value of N, returns the number of products a customer must purchase to have a p% (p is a value between 0 and 100) or greater probability of winning at least one prize.


minPurchasesRequired(4, 40) → 2
minPurchasesRequired(10, 50) → 7
minPurchasesRequired(1, 99) → 1

...Save, Compile, Run (ctrl-enter)

int minPurchasesRequired(int n, int p) { }

Editor font size %:
Shorter output


Forget It! -- delete my code for this problem

Progress graphs:
 Your progress graph for this problem
 Random user progress graph for this problem
 Random Epic Progress Graph

Java Help

Misc Code Practice

Difficulty: 5 Post-solution available

Copyright Nick Parlante 2017 - privacy