The BIG Pronic challenge
Description:
A pronic number is a composite integer that is the product of two consecutive integers -- in other words, every pronic number can be calculated as either n(n+1)
or n(n-1)
where n
is any integer. A related kata Figurate Numbers #2 - Pronic Number was fun and for the 32-bit integer problem space, a simple search-loop made solving that kata possible and a clever formula eliminated the need for a loop altogether.
This challenge will be different - this challenge is to write code that determines whether big -- REALLY BIG -- numbers are pronic. A naive loop through a billion or so numbers isn't going to work here. Provided is a non-loop based starter solution that generally works in the linked kata, but fails for the bigger data passed here.
Detail
- The tests you see are all you need to pass. There are no surprise tests to pass after the original tests are passing.
- These tests run your algorithm through over 300,000 numbers -- some pronic and some non-pronic. If your algorithm is reasonable, it should take considerably less than 6 seconds to complete.
- While authoring this kata, a couple large valued test-cases produced calculated pronics that appeared to be either much smaller than they should have or in some cases they even resulted in negative values. This was due to overflow and
unchecked
math, sochecked
block safeguards have been added to the tests to prevent accidental overflow for new and existing test-cases.
Similar Kata:
Stats:
Created | Sep 10, 2015 |
Published | Sep 12, 2015 |
Warriors Trained | 563 |
Total Skips | 99 |
Total Code Submissions | 493 |
Total Times Completed | 142 |
C# Completions | 72 |
Java Completions | 72 |
Fortran Completions | 9 |
Total Stars | 11 |
% of votes with a positive feedback rating | 86% of 48 |
Total "Very Satisfied" Votes | 37 |
Total "Somewhat Satisfied" Votes | 9 |
Total "Not Satisfied" Votes | 2 |
Total Rank Assessments | 10 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 3 kyu |
Lowest Assessed Rank | 8 kyu |