6 kyu

Build a pile of Cubes

31,716 of 89,330g964

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 Trained256656
Total Skips66856
Total Code Submissions352852
Total Times Completed89330
C# Completions5015
Java Completions9044
Ruby Completions2472
Python Completions31716
JavaScript Completions24072
CoffeeScript Completions75
Haskell Completions588
Clojure Completions158
Elixir Completions265
TypeScript Completions1875
C++ Completions4886
PHP Completions2287
Crystal Completions29
F# Completions111
C Completions2837
Swift Completions742
Rust Completions1427
Go Completions1895
R Completions239
Shell Completions46
OCaml Completions28
Fortran Completions38
Julia Completions94
NASM Completions36
Nim Completions26
Scala Completions273
Kotlin Completions729
Groovy Completions24
Dart Completions428
Pascal Completions26
Raku Completions14
Perl Completions43
COBOL Completions14
Elm Completions11
D Completions10
Erlang Completions20
Prolog Completions16
Total Stars3071
% of votes with a positive feedback rating86% of 8392
Total "Very Satisfied" Votes6377
Total "Somewhat Satisfied" Votes1718
Total "Not Satisfied" Votes297
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