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

 

gaurav.gupta@mq.edu.au variables > lastDigits
prev  |  next  |  chance

Define a function that when passed an integer and the required number of least-significant digits, returns a number containing the required value.

You can use Math.pow(10, x) to get the required power of 10, because, without that, you'll need loops to solve this one.


lastDigits(1729, 3) → 729
lastDigits(1729, 10) → 1729
lastDigits(92716174, 6) → 716174

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

int lastDigits(int n, int d) { }

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: 3 Post-solution available

Copyright Nick Parlante 2017 - privacy