Merge pull request #51 from erugged93/patch-1

Update BinaryToOctal.java
This commit is contained in:
Anup Kumar Panwar 2017-05-25 18:12:02 +05:30 committed by GitHub
commit 3907716e1f

View File

@ -29,7 +29,15 @@ public class BinaryToOctal {
* @return The octal number
*/
public static int convertBinaryToOctal(int b) {
int o = 0, r=0, j =1 ;
while(b!=0)
{
r = b % 10;
o = o + r * j;
j = j * 2;
b = b / 10;
}
return o;
}
}