美文网首页
高次方数的尾数

高次方数的尾数

作者: 一路向后 | 来源:发表于2021-10-21 21:22 被阅读0次

    1.问题描述

    求13的13次方的最后三位数。

    2.源码实现

    #include <stdio.h>
    #include <stdlib.h>
    #include <string.h>
    
    int main()
    {
        int a = 13;
        int n = 13;
        int s = 1;
        int i;
    
        for(i=0; i<n; i++)
        {
            s = a * s % 1000;
        }
    
        printf("%d\n", s);
    
        return 0;
    }
    

    3.编译源码

    $ gcc -o test test.c -std=c89
    

    4.运行及其结果

    ./test
    253
    

    相关文章

      网友评论

          本文标题:高次方数的尾数

          本文链接:https://www.haomeiwen.com/subject/toeqaltx.html