數字運算,判斷一個數是否接近素數
A Niven number is a number such that the sum of its digits divides itself. For example, 111 is a Niven number because the sum of its digits is 3, which divides 111. We can also specify a number in another base b, and a number in base b is a Niven number if the sum of its digits divides its value.
Given b (2 <= b <= 10) and a number in base b, determine whether it is a Niven number or not.
Input
Each line of input contains the base b, followed by a string of digits representing a positive integer in that base. There are no leading zeroes. The input is terminated by a line consisting of 0 alone.
Output
For each case, print "yes" on a line if the given number is a Niven number, and "no" otherwise.
Sample Input
10 111
2 110
10 123
6 1000
8 2314
0
Sample Output
yes
yes
no
yes
no
光學設計軟件zemax源碼:
This DLL models an nular aspheric
surface as described in:
"Annular surfaces in annular field systems"
By Jose M. Sasian
Opt. eng. 36 (12) P 3401-3401 December 1997
This surface is essentially an odd aspheric surface with an offset in the aspheric terms.
The sag is given by:
Z = (c*r*r) / (1+(1-((1+k)*c*c*r*r))^ 1/2 ) + a*(r-q)^2 + b*(r-q)^3 + c*(r-q)^4 + ...
Note the terms a, b, c, ... have units of length to the -1, -2, -3, ... power.
by Randal L. Schwartz and Tom Phoenix
ISBN 0-596-00132-0
Third Edition, published July 2001.
(See the catalog page for this book.)
the text of Learning Perl, 3rd Edition.
Table of Contents
Copyright Page
Preface
Chapter 1: Introduction
Chapter 2: Scalar Data
Chapter 3: Lists and Arrays
Chapter 4: Subroutines
Chapter 5: Hashes
Chapter 6: I/O Basics
Chapter 7: Concepts of Regular Expressions
Chapter 8: More About Regular Expressions
Chapter 9: Using Regular Expressions
Chapter 10: More Control Structures
Chapter 11: Filehandles and File Tests
Chapter 12: Directory Operations
Chapter 13: Manipulating Files and Directories
Chapter 14: Process Management
Chapter 15: Strings and Sorting
Chapter 16: Simple Databases
Chapter 17: Some Advanced Perl Techniques
Appendix A: Exercise Answers
Appendix B: Beyond the Llama
Index
Colophon
by Randal L. Schwartz and Tom Phoenix
ISBN 0-596-00132-0
Third Edition, published July 2001.
(See the catalog page for this book.)
Learning Perl, 3rd Edition.
Table of Contents
Copyright Page
Preface
Chapter 1: Introduction
Chapter 2: Scalar Data
Chapter 3: Lists and Arrays
Chapter 4: Subroutines
Chapter 5: Hashes
Chapter 6: I/O Basics
Chapter 7: Concepts of Regular Expressions
Chapter 8: More About Regular Expressions
Chapter 9: Using Regular Expressions
Chapter 10: More Control Structures
Chapter 11: Filehandles and File Tests
Chapter 12: Directory Operations
Chapter 13: Manipulating Files and Directories
Chapter 14: Process Management
Chapter 15: Strings and Sorting
Chapter 16: Simple Databases
Chapter 17: Some Advanced Perl Techniques
Appendix A: Exercise Answers
Appendix B: Beyond the Llama
Index
Colophon