C Exercise Example 85
100 cases of classic C language
Title: Analyzing a prime number divisible by 9 can be several.
Program analysis: Ah!This topic is to determine the meaning of a prime number divisible by 9 several numbers composed it? So I understand it. Prime number can not be divisible by 1 and itself in addition to the outside
Source Code:
// Created by www.w3big.com on 15/11/9. // Copyright © 2015年 本教程. All rights reserved. // #include<stdio.h> #include<stdlib.h> int main() { int p,i; long int sum=9; printf("请输入一个素数:\n"); scanf("%d",&p); for(i=1;;i++) if(sum%p==0)break; else sum=sum*10+9; printf("素数%d能整除%d个9组成的数%ld\n",p,i,sum); return 0; }
Run the above example output is:
请输入一个素数: 13 素数13能整除6个9组成的数999999