/* package whatever; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; import java.math.BigDecimal; /* Name of the class has to be "Main" only if the class is public. */ class Ideone { { } { for ( int i = 0 ; i <= decimalPlaces ; i++ ) { currentNumber = currentNumber.setScale( i ); while ( currentNumber.add( toAdd ).pow( 2 ).compareTo( num ) <= 0 ) { currentNumber = currentNumber.add( toAdd ); } } return currentNumber.toPlainString(); } }
Standard input is empty
0 >> 0 3.0 >> 1 3.40 >> 2 3.460 >> 3 3.4640 >> 4 3.46410 >> 5 3.464100 >> 6 3.4641010 >> 7 3.46410160 >> 8 3.464101610 >> 9 3.4641016150 >> 10 3.46410161510 >> 11 3.464101615130 >> 12 3.4641016151370 >> 13 3.46410161513770 >> 14 3.464101615137750 >> 15 3.4641016151377540 >> 16 3.46410161513775450 >> 17 3.464101615137754580 >> 18 3.4641016151377545870 >> 19 3.46410161513775458700 >> 20 3.464101615137754587050 >> 21 3.4641016151377545870540 >> 22 3.46410161513775458705480 >> 23 3.464101615137754587054890 >> 24 3.4641016151377545870548920 >> 25 3.46410161513775458705489260 >> 26 3.464101615137754587054892680 >> 27 3.4641016151377545870548926830 >> 28 3.46410161513775458705489268300 >> 29 3.464101615137754587054892683010 >> 30 3.4641016151377545870548926830110 >> 31 3.46410161513775458705489268301170 >> 32 3.464101615137754587054892683011740 >> 33 3.4641016151377545870548926830117440 >> 34 3.46410161513775458705489268301174470 >> 35 3.464101615137754587054892683011744730 >> 36 3.4641016151377545870548926830117447330 >> 37 3.46410161513775458705489268301174473380 >> 38 3.464101615137754587054892683011744733880 >> 39 3.4641016151377545870548926830117447338850 >> 40 3.46410161513775458705489268301174473388560 >> 41 3.464101615137754587054892683011744733885610 >> 42 3.4641016151377545870548926830117447338856100 >> 43 3.46410161513775458705489268301174473388561050 >> 44 3.464101615137754587054892683011744733885610500 >> 45 3.4641016151377545870548926830117447338856105070 >> 46 3.46410161513775458705489268301174473388561050760 >> 47 3.464101615137754587054892683011744733885610507620 >> 48 3.4641016151377545870548926830117447338856105076200 >> 49 3.46410161513775458705489268301174473388561050762070 >> 50 3.464101615137754587054892683011744733885610507620760 >> 51 3.4641016151377545870548926830117447338856105076207610 >> 52 3.46410161513775458705489268301174473388561050762076120 >> 53 3.464101615137754587054892683011744733885610507620761250 >> 54 3.4641016151377545870548926830117447338856105076207612560 >> 55 3.46410161513775458705489268301174473388561050762076125610 >> 56 3.464101615137754587054892683011744733885610507620761256110 >> 57 3.4641016151377545870548926830117447338856105076207612561110 >> 58 3.46410161513775458705489268301174473388561050762076125611160 >> 59 3.464101615137754587054892683011744733885610507620761256111610 >> 60 3.4641016151377545870548926830117447338856105076207612561116130 >> 61 3.46410161513775458705489268301174473388561050762076125611161390 >> 62 3.464101615137754587054892683011744733885610507620761256111613950 >> 63 3.4641016151377545870548926830117447338856105076207612561116139580 >> 64 3.46410161513775458705489268301174473388561050762076125611161395890 >> 65 3.464101615137754587054892683011744733885610507620761256111613958900 >> 66 3.4641016151377545870548926830117447338856105076207612561116139589030 >> 67 3.46410161513775458705489268301174473388561050762076125611161395890380 >> 68 3.464101615137754587054892683011744733885610507620761256111613958903860 >> 69 3.4641016151377545870548926830117447338856105076207612561116139589038660 >> 70 3.46410161513775458705489268301174473388561050762076125611161395890386600 >> 71 3.464101615137754587054892683011744733885610507620761256111613958903866030 >> 72 3.4641016151377545870548926830117447338856105076207612561116139589038660330 >> 73 3.46410161513775458705489268301174473388561050762076125611161395890386603380 >> 74 3.464101615137754587054892683011744733885610507620761256111613958903866033810 >> 75 3.4641016151377545870548926830117447338856105076207612561116139589038660338170 >> 76 3.46410161513775458705489268301174473388561050762076125611161395890386603381760 >> 77 3.464101615137754587054892683011744733885610507620761256111613958903866033817600 >> 78 3.4641016151377545870548926830117447338856105076207612561116139589038660338176000 >> 79 3.46410161513775458705489268301174473388561050762076125611161395890386603381760000 >> 80 result: 3.46410161513775458705489268301174473388561050762076125611161395890386603381760007