TA的每日心情 | 开心 2021-3-12 23:18 |
---|
签到天数: 2 天 [LV.1]初来乍到
|
C语言趣味程序百例精解之java实现(80)奇数平方.

程序:
- public class Test80{
- public static void main(String args[]){
- for(int i=1001;i<3000;i+=2){
- System.out.printf("%d:",i);
- System.out.printf("(%d*%d-1)/8",i,i);
- System.out.printf("=%d",(i*i-1)/8);
- System.out.printf("+%d
- ",(i*i-1)%8);
- }
- }
- }
- 程序仅验证到3000.
- 最后十个数为:
- 2981:(2981*2981-1)/8=1110795+0
- 2983:(2983*2983-1)/8=1112286+0
- 2985:(2985*2985-1)/8=1113778+0
- 2987:(2987*2987-1)/8=1115271+0
- 2989:(2989*2989-1)/8=1116765+0
- 2991:(2991*2991-1)/8=1118260+0
- 2993:(2993*2993-1)/8=1119756+0
- 2995:(2995*2995-1)/8=1121253+0
- 2997:(2997*2997-1)/8=1122751+0
- 2999:(2999*2999-1)/8=1124250+0
-
复制代码
源码下载:http://file.javaxxz.com/2014/11/25/000419375.zip |
|