6 kyu

Build a pile of Cubes

23,993 of 88,951g964

Description:

Your task is to construct a building which will be a pile of n cubes. The cube at the bottom will have a volume of n3 n^3 , the cube above will have volume of (n1)3 (n-1)^3 and so on until the top which will have a volume of 13 1^3 .

You are given the total volume m of the building. Being given m can you find the number n of cubes you will have to build?

The parameter of the function findNb (find_nb, find-nb, findNb, ...) will be an integer m and you have to return the integer n such as n3+(n1)3+(n2)3+...+13=m n^3 + (n-1)^3 + (n-2)^3 + ... + 1^3 = m if such a n exists or -1 if there is no such n.

Examples:

findNb(1071225) --> 45

findNb(91716553919377) --> -1

Mathematics
Algorithms

More By Author:

Check out these other kata created by g964

Stats:

CreatedJun 30, 2015
PublishedJun 30, 2015
Warriors Trained255855
Total Skips66770
Total Code Submissions351843
Total Times Completed88951
C# Completions4999
Java Completions9014
Ruby Completions2468
Python Completions31550
JavaScript Completions23993
CoffeeScript Completions73
Haskell Completions586
Clojure Completions157
Elixir Completions263
TypeScript Completions1862
C++ Completions4847
PHP Completions2278
Crystal Completions28
F# Completions110
C Completions2828
Swift Completions735
Rust Completions1414
Go Completions1883
R Completions238
Shell Completions43
OCaml Completions27
Fortran Completions37
Julia Completions93
NASM Completions35
Nim Completions25
Scala Completions270
Kotlin Completions725
Groovy Completions23
Dart Completions422
Pascal Completions25
Raku Completions13
Perl Completions42
COBOL Completions12
Elm Completions10
D Completions9
Erlang Completions18
Prolog Completions15
Total Stars3064
% of votes with a positive feedback rating86% of 8379
Total "Very Satisfied" Votes6367
Total "Somewhat Satisfied" Votes1716
Total "Not Satisfied" Votes296
Total Rank Assessments34
Average Assessed Rank
6 kyu
Highest Assessed Rank
4 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • g964 Avatar
  • NaMe613 Avatar
  • Chrono79 Avatar
  • naithar Avatar
  • kazk Avatar
  • JohanWiltink Avatar
  • monadius Avatar
  • Awesome A.D. Avatar
  • hobovsky Avatar
  • uniapi Avatar
  • xavierguihot Avatar
  • solitude Avatar
  • trashy_incel Avatar
  • user8436785 Avatar
  • akar-0 Avatar
  • Just4FunCoder Avatar
  • KayleighWasTaken Avatar
  • saudiGuy Avatar
Ad