当前位置:网站首页>Enter an integer with any number of bits, and output the sum of each bit of the number. For example: 1234 – > 10
Enter an integer with any number of bits, and output the sum of each bit of the number. For example: 1234 – > 10
2022-06-25 07:14:00 【Python's path to becoming a God】
Code :
package com.homework;
import java.util.Scanner;
public class Bit_Sum {
public static void main(String[] args) {
// TODO Auto-generated method stub
Scanner input = new Scanner(System.in);
System.out.print(" Enter an integer with any number of digits :");
long num = input.nextLong();
long a=0;
while(num>0) {
a += num%10;
num /= 10;
}
System.out.print(" Sum of each digit of the number :"+a);
}
}
Running results :

边栏推荐
- Torchserve pit avoidance Guide
- lotus v1.16.0-rc2 Calibration-net
- 我与CSDN的一年时光及大学经验分享
- Capable people never complain about the environment!
- 有了 MySQL 为什么要用 NoSQL?
- Editing the date formatting of x-axis tick labels in Matplotlib - editing the date formatting of x-axis tick labels in Matplotlib
- 我们不一样
- The upper and lower lines of the shell are merged into one line
- Controlling volume mixer
- Who can teach me how to learn SCM, what to learn first and how to get started?
猜你喜欢

レ / leilei

Keil debug view variable prompt not in scope

Navicat prevent new query from being deleted by mistake

Want to self-study SCM, do you have any books and boards worth recommending?

单片机IO详解(上拉 下拉 准双向 输入 输出 推挽 开漏)

MCU IO explanation (pull-up pull-down quasi bidirectional input / output push-pull open drain)

CTFHub-Web-信息泄露-目录遍历

分布式锁中的王者方案 - Redisson

Several schemes of traffic exposure in kubernetes cluster

R & D thinking 07 - embedded intelligent product safety certification required
随机推荐
Icon already includes gloss effects
Astronomers may use pulsars to detect merged supermassive black holes
The Rust Programming Language
Three laws of go reflection
Unity get resource path
How to recover redis data from snapshot(rdb file) copied from another machine?
Report on development status and investment strategy recommendations of global and Chinese graphite polystyrene board industry 2022-2028
Want to self-study SCM, do you have any books and boards worth recommending?
高效探索|ES地理位置查询的一次应用实践
Love Terminator
【工具分享】一款颜值与技能并重的软件
Why did Yanjing Beer come here?
Google extender address
Torchserve pit avoidance Guide
Cloning and importing DOM nodes
Reading sensor data with GPIO analog SPI interface
In depth analysis of Apache bookkeeper series: Part 3 - reading principle
What is the real future of hardware engineers?
2022 biological fermentation Exhibition (Jinan), which is a must read before the exhibition. The most comprehensive exhibition strategy will take you around the "fermentation circle"
Tp6 interface returns three elements