|
|
|||||
|
In the last issue we challenged you to write a slick program to find the factors of a number and to identify prime numbers. Here is one possible solution. Note N<1.7x1038 10 INPUT "TYPE
A POSITIVE INTEGER AND PRESS ENTER"; N QBASIC has another important mathematical function: MOD. Here is how it works: 64 MOD 9=1 as 64=7*9+1. So x MOD y gives the remainder when x is divided by y. In BASIC you can define a MOD function using the following command. DEF FNM(X)=X-INT(X/J)*J 1. Change line 50 and find factors using MOD function. 2. Change the program so that it prints only prime factors of N.
|
|||||
![]() |
|||||