kotlin 二进制_Kotlin程序将十进制转换为二进制

本文介绍如何使用Kotlin将十进制数转换为二进制。通过递归地将十进制数除以2并记录余数,直到十进制数变为0,从而实现转换。
摘要由CSDN通过智能技术生成

kotlin 二进制

We are given a decimal number and we will create a Kotlin program to convert decimal number to binary.

我们给了十进制数,我们将创建一个Kotlin程序将十进制数转换为二进制

To convert decimal number to binary, we will recursively divide the decimal number by 2 and save the remainder found till the decimal number vanquishes.

要将十进制数转换为二进制,我们将十进制数递归除以2,然后将找到的余数保存到十进制数消失。

Example:

例:

    Input:
    Decimal number = 12

    Recursive division: 
    
Number Quotient Remainder
12 6 0
6 3 0
3 1 1
1 0 1
Output: Here, we will read the remainders in reverse order which
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值