fork download
  1. /* b.bc */
  2. /* 20:06 2015-06-21 */
  3.  
  4. scale = 0
  5. n = 10^9
  6.  
  7. x[0] = 3
  8. x[1] = 5
  9. x[2] = 7
  10. x[3] = 11
  11. x[4] = 13
  12. x[5] = 17
  13. x[6] = 19
  14. x[7] = 23
  15. x[8] = 29
  16. x[9] = 31
  17.  
  18. s = 0
  19. for(i[0]=0; i[0]<=1; i[0]++){
  20. for(i[1]=0; i[1]<=1; i[1]++){
  21. for(i[2]=0; i[2]<=1; i[2]++){
  22. for(i[3]=0; i[3]<=1; i[3]++){
  23. for(i[4]=0; i[4]<=1; i[4]++){
  24. for(i[5]=0; i[5]<=1; i[5]++){
  25. for(i[6]=0; i[6]<=1; i[6]++){
  26. for(i[7]=0; i[7]<=1; i[7]++){
  27. for(i[8]=0; i[8]<=1; i[8]++){
  28. for(i[9]=0; i[9]<=1; i[9]++){
  29. k = 0
  30. for(j=0; j < 10; j++)
  31. k += i[j]
  32. if(k == 0) continue
  33.  
  34. y=1
  35. for(j=0; j<10; j++)
  36. if(i[j] == 1) y *= x[j]
  37. if(y > n) continue
  38. z = n / y
  39. a = ((y + y * z) * z / 2)
  40. if(k == 1) s += a
  41. if(k == 2) s -= a
  42. if(k == 3) s += a
  43. if(k == 4) s -= a
  44. if(k == 5) s += a
  45. if(k == 6) s -= a
  46. if(k == 7) s += a
  47. if(k == 8) s -= a
  48. if(k == 9) s += a
  49. }
  50. }
  51. }
  52. }
  53. }
  54. }
  55. }
  56. }
  57. }
  58. }
  59. print "n=", n,"\n"
  60. print "s",s,"\n"
  61. quit
  62. /* end */
  63. /* n=1000000000 */
  64. /* s347147851533059033 */
  65.  
  66.  
Success #stdin #stdout 0.04s 2364KB
stdin
Standard input is empty
stdout
n=1000000000
s347147851533059033