当前位置:网站首页>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 :

边栏推荐
- 我们不一样
- Efficient exploration | an application practice of ES geographical location query
- Hongmeng learning notes: creating layouts using XML
- 313. Binary sum
- Americo technology launches professional desktop video editing solution
- Shell command learning
- [learn shell programming easily]-5. Plan tasks
- [ACNOI2022]王校长的构造
- 哇哦,好丰富呀。
- CTFHub-Web-信息泄露-目錄遍曆
猜你喜欢

有了 MySQL 为什么要用 NoSQL?

What is the real future of hardware engineers?

Event registration | Apache pulsar x kubesphere online meetup is coming

【工具分享】一款颜值与技能并重的软件

R & D thinking 07 - embedded intelligent product safety certification required

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"

活动报名|Apache Pulsar x KubeSphere 在线 Meetup 火热报名中

What is the new business model of Taishan crowdfunding in 2022?

Kubernetes core components etcd details

joda. Time get date summary
随机推荐
Lotus windowsost manually triggers space-time proof calculation
100 times larger than the Milky way, Dutch astronomers found mysterious objects in deep space
アルマ / alchemy girl
Understand ZBrush carving software and game modeling analysis
[Shangshui Shuo series] day 4
313. Binary sum
Ctfhub web information disclosure directory traversal
MSG_ OOB MSG_ PEEK
Entry level use of flask
Is it possible to use Jasmine's toHaveBeenCalledWith matcher with a regular expression?
Streaming a large file using PHP
[learn shell programming easily]-5. Plan tasks
CTFHub-Web-信息泄露-目錄遍曆
alphassl通配符证书送一个月
Can we use function pointers in go- Can we have function pointers in Go?
有了 MySQL 为什么要用 NoSQL?
Simple and complete steps of vivado project
Kubernetes 集群中流量暴露的几种方案
Love Terminator
Blue Bridge Cup SCM module code (LED) (code + comments)