軟體實驗 Perfect Number Enumerating 虞台文. Perfect Numbers A perfect number is such that it is equal to the sum of its proper divisors, which are any divisors.

Slides:



Advertisements
Similar presentations
Sets and its element A set is a collection of well-defined and well-distinguished objects. The objects that make up a set are called the members or elements.
Advertisements

For(int i = 1; i
軟體實作與計算實驗 1  Roots of nonlinear functions  Nested FOR loops Lecture 5II.
MS-Excel XP Lesson 5. Exponentiation 1.A1  2 A2  3 A3  =A1^A2 B1  =2^4 2.^ for exponentiation.
Divisor máximo de dois inteiros. unsigned int gcd(unsigned int A, unsigned int B) { if (B > A) return gcd(B,A); else if (B==0) return A; else return gcd(B,A%B);}
Example 1 Dividing Integers Same sign, so quotient is positive. 5 = a. 8 – 40 – b. 14 – 2 = 7 – Different signs, so quotient is negative. c. 9 – 36 = 4.
Hints for homework 6.2. divisors A divisor of an integer n, also called a factor of n, is an integer which evenly divides n without leaving a remainder.
1 Introduction to Computers and Programming Class 3 Introduction to C Professor Avi Rosenfeld.
Starting Out with C++: Early Objects 5/e © 2006 Pearson Education. All Rights Reserved Starting Out with C++: Early Objects 5 th Edition Chapter 14 Recursion.
Consecutive Numbers Algebra I.
Program.-(4)* Write a program for input two integer number with message and display their sum. Algorithm steps Algorithm steps 1.Display message for input.
Chapter 5 Number Theory © 2008 Pearson Addison-Wesley. All rights reserved.
 2012 Pearson Education, Inc. Slide Chapter 5 Number Theory.
SECTION 5-3 Selected Topics from Number Theory Slide
1 Appendix E: Sigma Notation. 2 Definition: Sequence A sequence is a function a(n) (written a n ) who’s domain is the set of natural numbers {1, 2, 3,
Lesson No: 11 Working with Formula, Function, Chart & Excel Tools CHBT-01 Basic Micro process & Computer Operation.
What are factors? What makes a number prime or composite?
Additional Problems.
軟體實驗: C-Lab5 虞台文. Lab5 Problem Write a program which accepts a text file as input and outputs how many characters, lines, and words the file contains.
Operators in Python. Arithmetic operators Some operators in Python will look familiar (+, -, *, /) Others are new to you (%, //, **) All of these do work.
Adding and Subtracting Fractions
Section 6.5 Factoring by Grouping and a General Strategy for Factoring Polynomials.
Mixed Numbers and Improper Fractions Lesson 3-5. Vocabulary A proper fraction has a numerator that is less than its denominator. An improper fraction.
3.2 – Mixed number notation
Dividing Decimals TeacherTwins©2014. Warm Up
Arithmetic Expressions Addition (+) Subtraction (-) Multiplication (*) Division (/) –Integer –Real Number Mod Operator (%) Same as regular Depends on the.
軟體實作與計算實驗 1  While-loop flow chart  Decimal to binary representations Lecture 6 While-Loop programming.
Square Roots TSWBAT find square roots of perfect squares; find approximate roots of imperfect squares.
Lesson 3-5. Vocabulary A proper fraction has a numerator that is less than its denominator. An improper fraction has a numerator that is more than or.
軟體實驗: C-Lab7 虞台文. Lab7 Issues Lab 7-1  On-Off bits counting Lab 7-2  ACSII File Verification.
Irrational Numbers (4.2). If the definition of a rational number is a number that can be written in the form m/n, where m and n are integers with n not.
Print Row Function void PrintRow(float x[ ][4],int i) { int j; for(j=0;j
Basic Definitions of Set Theory Lecture 23 Section 5.1 Mon, Feb 21, 2005.
軟體實驗:實作以二分法開根號 虞台文. The Lab Problem Write a function to compute by bisection the square root of a positive integer n given by the caller. The function’s.
Discrete Mathematics Lecture # 10 Venn Diagram. Union  Let A and B be subsets of a universal set U. The union of sets A and B is the set of all elements.
CONSECUTIVE INTEGERS. CONSECUTIVE INTEGERS - Consecutive integers are integers that follow each other in order. They have a difference of 1 between each.
CS1010: Programming Methodology
Logarithms Common Logarithms Integer Logarithms Negative Logarithms Log of a Product Log of a Quotient Log of an Exponential Natural Logarithms.
Int fact (int n) { If (n == 0) return 1; else return n * fact (n – 1); } 5 void main () { Int Sum; : Sum = fact (5); : } Factorial Program Using Recursion.
Goal: use division to generate mixed numbers and improper fractions.
軟體實作與計算實驗 1  While loop  Positive integer square root  Decimal to binary transition Lecture 6 While Loop.
START HERE Startup: Place each value on the number line where it belongs.
R E C U R S I O N Legaspi, Ma. ArleneProf. Carmela Francisco MITSAT 8:00 am to 4pm.
Control Structures: Examples. for-loop example Q: If a=1, b=3, and x=7, what is the value of x when the loop terminates? A: x=1 for(k=a; k
Mixed Numbers and Improper Fractions
Mechanics of Functions
Objective - To factor trinomials in the form,
Greatest Common Divisor
Greatest Common Divisor
Natural Numbers Natural numbers are counting numbers.
Reducing a Fraction to Its Simplest Form
Consecutive Numbers Algebra I.
Perfect Squares & Estimating Square Roots
Focus on Expressions and Equations
Objective - To factor trinomials in the form,
The Rational Numbers Notes and Examples for 8/15/16
Consecutive Integers.
Mixed Numbers and Improper Fractions
Using Rules to Subtract Integers
For loops.
Relational Operators Operator Meaning < Less than > Greater than
Dr. Joe Anderson September 6, 2017
Mixed Numbers and Improper Fractions
Unit 4 Scientific Notation
The last lesson of this term!
Operations With Integers
Miniconference on the Mathematics of Computation
Dividing Integers ÷ = + ÷ = + ÷ = + ÷ =.
Intro To Adding Integers
Objective - To factor trinomials in the form,
Presentation transcript:

軟體實驗 Perfect Number Enumerating 虞台文

Perfect Numbers A perfect number is such that it is equal to the sum of its proper divisors, which are any divisors less than the number.perfect number Examples: – Proper divisors of 6  1, 2, 3 6  – Proper divisors of 10  1, 2, 5 10  – Proper divisors of 28  1, 2, 4, 7, 

Perfect Numbers A perfect number is such that it is equal to the sum of its proper divisors, which are any divisors less than the number.perfect number Examples: – Proper divisors of 6  1, 2, 3 6  – Proper divisors of 10  1, 2, 5 10  – Proper divisors of 28  1, 2, 4, 7,   : perfect  : imperfect

The Problem Write a program to determine all the perfect numbers between 1 and

Helper Functions int IsPerfect(int n) returns 1 if n is perfect and 0 otherwise. int NextPropDiv(int now, int n) now  the current proper divisor of n returns the next proper divisor if it exists, and 0 otherwise.

The Problem A perfect number is such that it is equal to the sum of its proper divisors, which are any divisors less than the number. For example, 6 is a perfect number because 6 = , and 28 is another perfect number because 28 = Write a program to determine all the perfect numbers between 1 and Your program should include functions int IsPerfect(int n) and int NextPropDiv(int now, int n). Function IsPerfect takes an integer n and returns 1 if n is perfect and 0 otherwise. Function NextPropDiv takes two integers now and n, now denoting the current proper divisor of n, and returns the next proper divisor if it exists, and 0 if it does not. A perfect number is such that it is equal to the sum of its proper divisors, which are any divisors less than the number. For example, 6 is a perfect number because 6 = , and 28 is another perfect number because 28 = Write a program to determine all the perfect numbers between 1 and Your program should include functions int IsPerfect(int n) and int NextPropDiv(int now, int n). Function IsPerfect takes an integer n and returns 1 if n is perfect and 0 otherwise. Function NextPropDiv takes two integers now and n, now denoting the current proper divisor of n, and returns the next proper divisor if it exists, and 0 if it does not.