6 kyu

Build a pile of Cubes

23,856 of 88,351g964

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 Trained254608
Total Skips66536
Total Code Submissions350521
Total Times Completed88351
C# Completions4973
Java Completions8970
Ruby Completions2463
Python Completions31293
JavaScript Completions23856
CoffeeScript Completions73
Haskell Completions580
Clojure Completions156
Elixir Completions261
TypeScript Completions1844
C++ Completions4811
PHP Completions2266
Crystal Completions27
F# Completions110
C Completions2817
Swift Completions732
Rust Completions1398
Go Completions1863
R Completions237
Shell Completions43
OCaml Completions27
Fortran Completions37
Julia Completions93
NASM Completions34
Nim Completions25
Scala Completions270
Kotlin Completions720
Groovy Completions23
Dart Completions414
Pascal Completions25
Raku Completions12
Perl Completions42
COBOL Completions12
Elm Completions10
D Completions9
Erlang Completions18
Prolog Completions15
Total Stars3053
% of votes with a positive feedback rating86% of 8359
Total "Very Satisfied" Votes6352
Total "Somewhat Satisfied" Votes1712
Total "Not Satisfied" Votes295
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