5.15 Perfect Number in Java

  Рет қаралды 144,584

Telusko

Telusko

8 жыл бұрын

In this video we will check whether a number is perfect number or not. A perfect number is a positive integer that is equal to the sum of its proper positive divisors excluding itself. The first perfect number is 6, because 6=1 + 2 + 3.
A perfect number is a positive integer that is equal to the sum of its proper positive divisors, that is, the sum of its positive divisors excluding the number itself .
Check out our website: www.telusko.com
Follow Telusko on Twitter: / navinreddy20
Follow on Facebook:
Telusko : / teluskolearnings
Navin Reddy : / navintelusko
Follow Navin Reddy on Instagram: / navinreddy20
Subscribe to our other channel:
Navin Reddy : / @navinreddy
Telusko Hindi :
/ @teluskohindi
Subscribe to the channel and learn Programming in easy way.
Java Tutorial for Beginners: goo.gl/p10QfB
C Tutorial Playlist : goo.gl/8v92pu
Android Tutorial for Beginners Playlist : goo.gl/MzlIUJ
XML Tutorial : goo.gl/Eo79do
Design Patterns in Java : goo.gl/Kd2MWE
Socket Programming in Java : goo.gl/jlMEbg
Spring MVC Tutorial : goo.gl/9ubbG2
OpenShift Tutorial for Beginners : goo.gl/s58BQH
Spring Framework with Maven : goo.gl/MaEluO
Sql Tutorial for Beginners : goo.gl/x3PrTg
String Handling in Java : goo.gl/zUdPwa
Array in Java : goo.gl/uXTaUy
Java Servlet : goo.gl/R5nHp8
Exception Handling in Java : goo.gl/N4NbAW

Пікірлер: 51
@caribbeanman3379
@caribbeanman3379 8 жыл бұрын
It is good practice to always use { } with your *if*, *for* and other block statements - even if the statement is just one line. Why? If you fail to enclose a single line block statement with { }, you may later add a second line to the block statement and forget to add the { } (in which case you wouldn't actually be adding a new line to the block statement even though you might think you are). This will introduce a logic error that is extremely difficult to find since no errors will be thrown by the compiler.
@SmartProgramming
@SmartProgramming 6 жыл бұрын
thats new for me, thanks for this program sir 👍👍
@kavyavadla3322
@kavyavadla3322 7 жыл бұрын
i think its can be possible with while loop { int i,n,sum=0; while (i
@jamunasuresh8352
@jamunasuresh8352 Жыл бұрын
Can you please explain the program for the following question: Write a program to accept 'n' numbers and stop if the user enters multiple of 7.
@prathammishra4480
@prathammishra4480 5 жыл бұрын
Uncle why is your voice to some extent like a robot ???
@yezralama2507
@yezralama2507 7 жыл бұрын
hello sir .This syntax is not working in eclipse. there is no link between int n in two methods. So can you help me.
@yugalsingh154
@yugalsingh154 4 жыл бұрын
facing the same issue.
@vampiriclion1176
@vampiriclion1176 4 жыл бұрын
You can also return n == sum, without using if statement
@sanisan5787
@sanisan5787 4 жыл бұрын
Sir if we can take i
@sathishakula6998
@sathishakula6998 3 жыл бұрын
Every number is a factor of itself. So if we take like that then sum will be more than the entered number .Then we won't get any number as perfect number.
@abhishekvenkataraman4908
@abhishekvenkataraman4908 3 жыл бұрын
this is for 3 digit right? if the input is not known what should we do?.Like ahould we import scanner and then like reversin Can anyone explain me
@souvikroy3740
@souvikroy3740 7 жыл бұрын
package project4; import java.util.Scanner; public class proj4 { public static void main(String[] arg){ /* PERFECT NUMBER*/ Scanner sc1 = new Scanner(System.in); System.out.println("Enter your number"); int x1 = sc1.nextInt(); int sum=0; for(int i=1;i
@sagarsahu2555
@sagarsahu2555 5 жыл бұрын
Sir plz make a video for Happy number in java with code
@ndawallah782
@ndawallah782 4 жыл бұрын
Very very thanks
@NishaMeenachocolover
@NishaMeenachocolover 8 жыл бұрын
Hi How can we use scanner in the same program to get input from user. Thanks in Advance
@medhabobbili5018
@medhabobbili5018 8 жыл бұрын
We should use import java.util.Scanner function and write class scanner with object and call it.
@parasarora2606
@parasarora2606 8 жыл бұрын
scanner is predefined class in java.To use this u make a obj for this class eg-> scanner obj =new scanner(System.in); int x=obj.nextInt(); //for integer
@user-pc2kx7kv1y
@user-pc2kx7kv1y 5 жыл бұрын
import java.util.*; public class Perfect { public static void main(String[] args)throws Exception { int sum=0; Scanner sc=new Scanner(System.in); System.out.println("ENTER ANY NUMBER"); int n = sc.nextInt(); for(int i=1;i
@jibanjyotijena9070
@jibanjyotijena9070 6 жыл бұрын
Sir.... Actually I didn't get you.plz elaborate , what are those function and argument .why we follow this process instead of normal procedure
@dannyg8682
@dannyg8682 6 жыл бұрын
I am not sure what you mean by normal procedure, but he is just showing you how to think in a way that will help you when you are actually trying to find solutions while writing a program. The Prime number method he used is simple but looks complicated and he didn't explain what he was doing very well. First he gives n a value, say 28 and then he runs the program which divides 28 by i checking the remainder for 0, and i is increasing on every loop 1, then 2, then 3 until it gets to 28 and stops. it puts all the numbers that had no remainders in the sum variable adding them up to see if the factors add up to be the same number he originally put in. If the remainder was not 0 that number does not go into the sum variable. for 28 the sum variable got 1+2+4+7+14 because all those numbers have a remainder of 0. If he used six he would get 1+2+3 in the sum variable because all those numbers have a remainder of zero. And if you were to use the number 10, it would put 1+2+5 in the sum and that does not equal ten so 10 is not a perfect number but 28 and 6 are perfect numbers
@bhaveshaudichya
@bhaveshaudichya 6 жыл бұрын
if i want print all factors also what should i do
@sunilreddy9297
@sunilreddy9297 6 жыл бұрын
Inside If block, Print 'i' value, It will give u all the factors of the number
@bhaveshaudichya
@bhaveshaudichya 6 жыл бұрын
thanku
@evanexcel7148
@evanexcel7148 5 жыл бұрын
import java.util.Scanner; public class Main { public static void main(String[] args) { System.out.println("Enter the number to check if it is perfect"); Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int sum =0; for(int i =1;i
@prathammishra4480
@prathammishra4480 5 жыл бұрын
@@sunilreddy9297 Are you his brother ????
@jasonbhatnagar7134
@jasonbhatnagar7134 6 жыл бұрын
Does anyone know how to write a program like this except it only shows the perfect numbers up to number entered? So if I entered 1, no perfect number would show. If I then entered 100, 6 and 28 would show. If 1000, then 6, 28, and 496 would show. If 10000, then those three and 8128 would show. Also, the program should show the factors of each perfect number in the ouput.
@user-pc2kx7kv1y
@user-pc2kx7kv1y 5 жыл бұрын
Jason Bhatnagar import java.util.*; public class Perfect { public static void main(String[] args)throws Exception { int sum=0; Scanner sc=new Scanner(System.in); System.out.println("ENTER ANY NUMBER"); int n = sc.nextInt(); for(int i=1;i
@sanathboddhula4599
@sanathboddhula4599 5 жыл бұрын
code isn't working
@Anilkumar-ec8sj
@Anilkumar-ec8sj 8 жыл бұрын
/*Wrote a simple program */ public class PerfectNumber { public static void main(String[] args) { int n =22; int temp; int sum=0; temp = n; for(int i = 1; i
@vemurisaikrishna9079
@vemurisaikrishna9079 8 жыл бұрын
/* * To change this template, choose Tools | Templates * and open the template in the editor. */ package myproj; import java.util.Scanner; /** * * @author Vemuri Sai Krishna */ public class perfectnum { public static void main(String[] args){ int i,s=0,n; System.out.println("enter a number"); Scanner in = new Scanner(System.in); n = in.nextInt(); for(i=1;i
@thespiritualjourney369
@thespiritualjourney369 3 жыл бұрын
your every programs are soooo complicated when they CAN be so easy.
@RS-ux5zu
@RS-ux5zu 6 жыл бұрын
how to find a logic ?
@shuvshaw9594
@shuvshaw9594 4 жыл бұрын
int x=6, sum=0; for(int i=1; i
@varunshandilya7456
@varunshandilya7456 5 жыл бұрын
why i am getting output always as it is not perfect number...my code is same public class PerfectNumber { public static void main(String[] args) { int n=6; boolean b=isperfect(n); if(b) { System.out.println("perfect"); } else { System.out.println("not"); } } public static boolean isperfect(int n) { int sum=0; for(int i=1;i
@harisharma8500
@harisharma8500 5 жыл бұрын
Just type n in place of n/2 in for loop.
@varunshandilya7456
@varunshandilya7456 5 жыл бұрын
@@harisharma8500 thanks...bro
@nithyashreenaidu8357
@nithyashreenaidu8357 4 жыл бұрын
you have to put
@anjalidubey6972
@anjalidubey6972 3 жыл бұрын
5. Write a Java program to check whether a number is an Q5 Number(changed the original name) or not. In recreational mathematics, a Q5 number in a given number base, is an integer that is divisible by the sum of its digits when written in that base. Can u please solve this i can't get the question 😟😟
@vignesh4062
@vignesh4062 3 жыл бұрын
import java.util.*; class Main { public static void main(String args[]) { Scanner sc = new Scanner(System.in); System.out.print("Enter a number : "); int n = sc.nextInt(); int x = n, d, sum = 0; //finding sum of digits while(x>0) { d = x%10; sum = sum + d; X = x/10; } if(n%sum == 0) System.out.println(n+" is a Q5 number."); else System.out.println(n+" is not a Q5 number"); } }
@user-pc2kx7kv1y
@user-pc2kx7kv1y 5 жыл бұрын
package com.example; import java.util.*; public class Perfect { public static void main(String[] args)throws Exception { int sum=0; Scanner sc=new Scanner(System.in); System.out.println("ENTER ANY NUMBER"); int n = sc.nextInt(); for(int i=1;i
@venkateswarluguntaka7370
@venkateswarluguntaka7370 4 жыл бұрын
@charanguggulla6899
@charanguggulla6899 7 жыл бұрын
class Perfect{ public static void main(String charan[]){ int i,j,k,sum=0; i=28; j=i; while(0!=j--){ if(j==0)break; if(i%j==0){ sum=sum+j; } } if(i==sum){System.out.println("it is perfectnumber");} else System.out.println("it is NOT perfectnumber"); }}
@anjelaryal6249
@anjelaryal6249 3 жыл бұрын
/* As I dont know much about method, I wrote a simple one*/ public class KZbin { public static void main(String [] args){ int n = 28; int sum = 0; for(int i = 1;i
@sowmyaburgula5359
@sowmyaburgula5359 3 жыл бұрын
This is simple and easy to understand thanks :)
@evanexcel7148
@evanexcel7148 5 жыл бұрын
This way also it works- Let me know your thoughts as well import java.util.Scanner; public class Main { public static void main(String[] args) { System.out.println("Enter the number to check if it is perfect"); Scanner sc = new Scanner(System.in); int n = sc.nextInt(); int sum =0; for(int i =1;i
@shivaprakashreddyyeredla1705
@shivaprakashreddyyeredla1705 2 жыл бұрын
I didn't understand this vedio
@elangovan2045
@elangovan2045 7 жыл бұрын
लसनगजलचु
@pravarkunnath3519
@pravarkunnath3519 3 жыл бұрын
istg brh this launguage makes me wanna kms
5.16 Armstrong Number in Java
6:01
Telusko
Рет қаралды 304 М.
5.19 Swapping of 2 Numbers in Easy way
3:20
Telusko
Рет қаралды 73 М.
ОСКАР ИСПОРТИЛ ДЖОНИ ЖИЗНЬ 😢 @lenta_com
01:01
孩子多的烦恼?#火影忍者 #家庭 #佐助
00:31
火影忍者一家
Рет қаралды 43 МЛН
Incredible magic 🤯✨
00:53
America's Got Talent
Рет қаралды 21 МЛН
Неприятная Встреча На Мосту - Полярная звезда #shorts
00:59
Полярная звезда - Kuzey Yıldızı
Рет қаралды 7 МЛН
FIND GIVEN NUMBER IS PRIME OR NOT IN JAVA
0:50
SiriSree Tech Tutorials
Рет қаралды 15 М.
Factorial of a number - Java Program.
0:56
Harish Coding_Puzzle
Рет қаралды 13 М.
Find Prime Numbers In Java - Full Walkthrough with Source
13:17
Coding with John
Рет қаралды 35 М.
Binary Explained in 01100100 Seconds
2:27
Fireship
Рет қаралды 430 М.
100+ Linux Things you Need to Know
12:23
Fireship
Рет қаралды 135 М.
Java Program #11 - Find Armstrong Number in Java
11:09
Programming For Beginners
Рет қаралды 15 М.
ОСКАР ИСПОРТИЛ ДЖОНИ ЖИЗНЬ 😢 @lenta_com
01:01